Documentation ¶
Index ¶
- func ElapsedTime(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- func ErrorIf(condition bool, status int) func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- func ErrorWhen(condition func() (bool, error), status int) func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- func If(condition bool, then http.HandlerFunc) func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- func MiddlewareIf(condition bool, ...) func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- func MiddlewareWhen(condition func() (bool, error), ...) func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- func When(condition func() (bool, error), then http.HandlerFunc) func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- type Headers
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ElapsedTime ¶
func ElapsedTime(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
ElapsedTime add requset elapsed time to "Elapsed-Time" header of response. Elapsed time is time spent between middleware exetue and data wrote to response.
func ErrorIf ¶
func ErrorIf(condition bool, status int) func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
ErrorIf middleware return http error if condition is true.
func ErrorWhen ¶
func ErrorWhen(condition func() (bool, error), status int) func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
ErrorWhen middleware return http error if result of condition function is true. Panic if any error raised.
func If ¶
func If(condition bool, then http.HandlerFunc) func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
If middleware checks condition. If condition is true,params 'then' will be executed. Only checks condition when init.
func MiddlewareIf ¶
func MiddlewareIf(condition bool, then func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)) func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
MiddlewareIf return middleware after condition checked. If condition is true,mirddleware 'then' will be returned. Only checks condition when init.
func MiddlewareWhen ¶
func MiddlewareWhen(condition func() (bool, error), then func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)) func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
MiddlewareWhen return middleware after condition checked. If result of condition function is true,params 'then' will be executed. Panic if any error raised. Checks condition every time.
func When ¶
func When(condition func() (bool, error), then http.HandlerFunc) func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
When middleware checks condition. If result of condition function is true,params 'then' will be executed. Panic if any error raised. Checks condition every time.
Types ¶
type Headers ¶
Headers headers middleware which add headers to each response
func (*Headers) ServeMiddleware ¶
func (h *Headers) ServeMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
ServeMiddleware serve headers settings as middleware