Documentation ¶
Index ¶
- Constants
- func Decode(hash string) ([]byte, error)
- func Generate(keysize int) string
- func GetUsername(ctx context.Context) string
- func JSONResponse(w http.ResponseWriter, o interface{})
- func JSONStatusResponse(code int, w http.ResponseWriter, o interface{})
- func MatchingFiles(dir string, extensions ...string) []string
- func NewStaticFileHandler(filenames ...string) http.Handler
- func NewTemplateHandler(filenames ...string) http.Handler
- func QueryParamKeys(v url.Values) []string
- func Redirect(w http.ResponseWriter, r *http.Request, targetURL string, ...)
- func SetUsername(ctx context.Context, username string) context.Context
- type KeyProvider
- type Middleware
- type PasswordChecker
- type RequestChecker
Constants ¶
const ( // HashKeySize is optimally 64 bytes HashKeySize = 64 // BlockKeySize is optimally 32 bytes BlockKeySize = 32 )
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
Generate creates a random key of keysize length, and returns it in base64 encoded text.
func GetUsername ¶ added in v0.0.7
GetUsername retrieves authenticated username from Context
func JSONResponse ¶
func JSONResponse(w http.ResponseWriter, o interface{})
JSONResponse writes the interface{} o as a JSON object response body.
func JSONStatusResponse ¶
func JSONStatusResponse(code int, w http.ResponseWriter, o interface{})
JSONStatusResponse writes the interface{} o as a JSON object response body with the givent http status code.
func MatchingFiles ¶ added in v0.2.0
MatchingFiles returns the names of all the files in dir with (case insensitive) extension matching one of extensions.
func NewStaticFileHandler ¶ added in v0.2.0
NewStaticFileHandler tries each filename parameter and serves the first one successfully read, or returns 404 if none are found.
func NewTemplateHandler ¶ added in v0.2.0
NewTemplateHandler loads each filename parameter as a template, and serves the first one to match, or returns 404 if one is not found.
func QueryParamKeys ¶
QueryParamKeys gets the keys from a url.Values collection.
Types ¶
type KeyProvider ¶ added in v0.0.7
KeyProvider describes functions needed for encrypted cookies.
func DefaultKeyProvider ¶ added in v0.0.7
func DefaultKeyProvider() (KeyProvider, error)
DefaultKeyProvider creates random default values for the provider. This is only good for one execution run, unless the generated keys are persisted.
func NewKeyProvider ¶ added in v0.0.7
func NewKeyProvider(hash string, block string) (KeyProvider, error)
NewKeyProvider creates a default provider from base64 encoded values.
type Middleware ¶ added in v0.1.0
type Middleware interface {
ServeHTTP(http.ResponseWriter, *http.Request, http.HandlerFunc)
}
Middleware describes common middleware
func NewDebugMiddleware ¶
func NewDebugMiddleware(w io.Writer, verbose bool) Middleware
NewDebugMiddleware provides middleware suitable for exhaustive request/response logging.
type PasswordChecker ¶ added in v0.0.7
PasswordChecker describes functionality to verify passwords
func PasswordCheckers ¶ added in v0.0.7
func PasswordCheckers(checkers ...PasswordChecker) PasswordChecker
PasswordCheckers combines multiple PasswordCheckers
type RequestChecker ¶ added in v0.0.7
RequestChecker describes functionality to verify requests
func RequestCheckers ¶ added in v0.0.7
func RequestCheckers(checkers ...RequestChecker) RequestChecker
RequestCheckers combines multiple RequestCheckers