httputil

package
v0.0.0-...-3eddca5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2017 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrShortKey = errors.New("Signing/encryption keys must be 32 characters")
	ErrGenIV    = errors.New("Failed to generate initialization vector")
	ErrBadSig   = errors.New("Invalid signature")
	ErrBadData  = errors.New("Invalid input data")
)
View Source
var MaxMemory int64 = 4194304

Functions

func CleanUpTmpDir

func CleanUpTmpDir(tmpDir string)

Delete the temporary directory created by the `SaveFormFilesToTmp` function.

func DecodeForm

func DecodeForm(
	r *http.Request, ps httprouter.Params, args interface{},
) error

Decode form arguments. Arguments are first pulled from the URL (httprouter), then from the form.

func DecodeJSON

func DecodeJSON(r *http.Request, args interface{}) error

func LoadSession

func LoadSession(r *http.Request, key string, session interface{}) error

func Redirect

func Redirect(
	w http.ResponseWriter, r *http.Request, URL string, args ...interface{},
)

Redirect with 302 status. This isn't the most modern way to do this, but it seems to be more robust in older browsers.

func RespondJSON

func RespondJSON(w http.ResponseWriter, obj interface{})

func SaveFormFileToTmp

func SaveFormFileToTmp(r *http.Request, key string) (string, string, error)

func SaveFormFilesToTmp

func SaveFormFilesToTmp(r *http.Request) (string, []string, error)

Save posted file to a temporary directory and file, returning the directory, to full path to each file, and an error.

Use CleanUpTmpDir to delete the temporary directory created.

func SetSchemaDecoder

func SetSchemaDecoder(decoder *schema.Decoder)

Override the default schema decoder.

func SetSessionKeys

func SetSessionKeys(signingKey, cryptKey []byte)

Both keys should be 32 bytes.

func StoreSession

func StoreSession(
	w http.ResponseWriter, key string, maxAge int, session interface{},
) error

Types

type TokenHandler

type TokenHandler struct {
	// contains filtered or unexported fields
}

func NewTokenHandler

func NewTokenHandler(signingKey, cryptKey []byte) (TokenHandler, error)

func (TokenHandler) Decode

func (h TokenHandler) Decode(encoded64 []byte, value interface{}) error

func (TokenHandler) Encode

func (h TokenHandler) Encode(value interface{}) ([]byte, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL