Documentation ¶
Index ¶
- Variables
- func AllowedMethods(allowedMethods []string) func(f http.HandlerFunc) http.HandlerFunc
- func BasicAuthenticate(logger *log.Logger, authFn AuthFn, realm string) func(http.HandlerFunc) http.HandlerFunc
- func GetUser(r *http.Request) (string, error)
- func Noop(f http.HandlerFunc) http.HandlerFunc
- func PanicInterceptor(f http.HandlerFunc) http.HandlerFunc
- func PanicInterceptorWithLogger(logger *log.Logger) func(f http.HandlerFunc) http.HandlerFunc
- func SetHeaders(headers map[string]string) func(f http.HandlerFunc) http.HandlerFunc
- func TimeTrack(logger *log.Logger) func(f http.HandlerFunc) http.HandlerFunc
- type AuthFn
Constants ¶
This section is empty.
Variables ¶
View Source
var ( UserKey = "_user_id_" ErrUnknownUser = errors.New("unknown user") ErrEmptyList = errors.New("empty user list provided") ErrNoUserProvided = errors.New("no user provided in request context") ErrAuthHeaderWrongLength = errors.New("wrong length of authorization value") ErrMissingAuthHeader = errors.New("missing authorization header") )
Functions ¶
func AllowedMethods ¶
func AllowedMethods(allowedMethods []string) func(f http.HandlerFunc) http.HandlerFunc
func BasicAuthenticate ¶
func BasicAuthenticate(logger *log.Logger, authFn AuthFn, realm string) func(http.HandlerFunc) http.HandlerFunc
BasicAuthenticate setups authenticate headers in request, and handles authenticate based on authFn. In case of valid user authentication, it also set user id (that was returned from authFn) in request's context, and can be retrieved by GetUser function.
func Noop ¶
func Noop(f http.HandlerFunc) http.HandlerFunc
func PanicInterceptor ¶
func PanicInterceptor(f http.HandlerFunc) http.HandlerFunc
func PanicInterceptorWithLogger ¶
func PanicInterceptorWithLogger(logger *log.Logger) func(f http.HandlerFunc) http.HandlerFunc
func SetHeaders ¶
func SetHeaders(headers map[string]string) func(f http.HandlerFunc) http.HandlerFunc
func TimeTrack ¶
func TimeTrack(logger *log.Logger) func(f http.HandlerFunc) http.HandlerFunc
Types ¶
type AuthFn ¶
func Authenticate ¶
Authenticate verify credentials against provided user and password.
func AuthenticateMap ¶
Authenticate verify credentials against provided map (user => password).
Click to show internal directories.
Click to hide internal directories.