Documentation
¶
Index ¶
- Constants
- func CtxRequestIDHeader(r *http.Request) string
- func CtxRequestPath(r *http.Request) string
- func PanicRecovery(handler http.Handler) http.Handler
- func RequestIDHeader(h http.Handler) http.Handler
- func RequestPath(h http.Handler) http.Handler
- func Router(h http.HandlerFunc, middleware ...rtr) http.HandlerFunc
- func Server(h http.Handler, middleware ...srv) http.Handler
Constants ¶
const CtxRequestIDHeaderKey = ctxRequestIDHeader(iota)
const CtxRequestPathKey = ctxRequestPath(iota)
Variables ¶
This section is empty.
Functions ¶
func CtxRequestIDHeader ¶ added in v0.0.2
CtxRequestIDHeader retrieves the `X-Request-ID` from the current request `context`.
func CtxRequestPath ¶
CtxRequestPath retrieves the request path from the current request `context`.
func PanicRecovery ¶
PanicRecovery catches all `panic` calls in order to prevent HTTP server from going down and returns a standardised `500 Internal Server Error` response.
func RequestIDHeader ¶ added in v0.0.2
RequestIDHeader is a server level middleware and called on every request to handle `X-Request-ID` header. If the header already exists in the request, nothing else is done otherwise a new UUID V4 format is generated and added to request `context` as `X-Request-ID` header.
func RequestPath ¶
RequestPath is a server level middleware and called on every request to construct request path as in `{method} {uri}` format and added to request `context`.
func Router ¶
func Router(h http.HandlerFunc, middleware ...rtr) http.HandlerFunc
Router allows router level middleware chaining. The first middleware in the chain runs last. Server level middleware always take precedence over router level middleware.
Types ¶
This section is empty.