# README
Middleware
A collections of mux / router agnostic middlewares.
All middleware takes and returns http.Handler
; you can of course use http.HandlerFunc
instead by casting your
http.Handler
with http.HandlerFunc(myHandler)
.
For usage examples please refer to:
# Functions
Cache will store the response bytes into cache based on the key generated supplied.
ContentNoSniff sends X-Content-Type-Options header.
CSP sends Content Security Policy header.
CSRF sends custom header that in turn causes the request to considered "complex" and therefore CORS will apply.
Duration will track the duration (and usage) of the method.
DurationStatus is similar to Duration but also tracks the HTTP response code (via tags) It is based on statsD but it could be used with other metrics clients.
HSTS sends HTTP Strict Transport Security header.
InputBody will attempt to populate a copy of the supplied struct and store it in request context.
InputBodyDTO returns the populated DTO for this request (or nil).
InputBodySetDTO sets the supplied DTO into the context.
OutputJSON will attempt to encode the supplied DTO into JSON bytes and add to the response.
Panic will catch all panics, optionally log the stack trace and set the response to `http.StatusInternalServerError`.
Version will apply a version header to all responses.
XXSS sends X-XSS-Protection response header
By default the "mode=block" is not sent.
# Interfaces
CSRFLogger allows for logging.
InputBodyLogger allows for logging.
MetricsClient allows for tracking the endpoint via StatsD or similar.