Documentation
¶
Index ¶
- Constants
- func ID(h http.Handler) http.Handler
- func IDFromContext(r *http.Request) string
- func Info(h http.Handler) http.Handler
- func MethodFromContext(r *http.Request) string
- func PathFromContext(r *http.Request) string
- func ProtocolFromContext(r *http.Request) string
- func ValidateURLQueryLimitParam(v string, maxLimit int) (int, bool)
- func ValidateURLQueryOrderParam(v string, allowed map[string]string) (map[int]string, bool)
- func ValidateURLQueryPageParam(v string) (int, bool)
Constants ¶
const ( CtxRequestProtocolKey ctxInfo = iota CtxRequestMethodKey CtxRequestPathKey )
const ( URLQueryPageParam = "page" URLQueryLimitParam = "limit" URLQueryOrderParam = "order" )
const CtxRequestIDKey = ctxID(iota)
Variables ¶
This section is empty.
Functions ¶
func ID ¶ added in v0.0.4
ID is a server level middleware. It is 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`.
func IDFromContext ¶ added in v0.0.20
IDFromContext retrieves the `X-Request-ID` from the current request `context`.
func Info ¶ added in v0.0.4
Info is a server level middleware. It is called on every request to construct request protocol, method and path values then added to request `context`.
func MethodFromContext ¶ added in v0.0.20
MethodFromContext retrieves the request method from the current request `context`.
func PathFromContext ¶ added in v0.0.20
PathFromContext retrieves the request path from the current request `context`.
func ProtocolFromContext ¶ added in v0.0.20
ProtocolFromContext retrieves the request protocol from the current request `context`.
func ValidateURLQueryLimitParam ¶ added in v0.0.21
ValidateURLQueryLimitParam converts incoming `limit` parameter (v) to a valid `int` type. If the value is empty, `10` is returned as default.
func ValidateURLQueryOrderParam ¶ added in v0.0.21
ValidateURLQueryOrderParam extracts comma separated fields from the `order` parameter (v), iterates and compares them against the allowed set of fields (allowed). Empty `order` parameter is considered as a valid input. Any empty field, duplicated field and non-matching field are all considered as an invalid input.
func ValidateURLQueryPageParam ¶ added in v0.0.21
ValidateURLQueryPageParam converts incoming `page` parameter (v) to a valid `int` type. If the value is empty, `1` is returned as default.
Types ¶
This section is empty.