Documentation ¶
Index ¶
- func AllowContentType(contentTypes ...string) func(http.Handler) http.Handler
- func AllowHTTPHeader(badStatus int, name string, values ...string) func(http.Handler) http.Handler
- func AllowMethod(methods ...string) func(http.Handler) http.Handler
- func AllowUserAgent(userAgents ...string) func(http.Handler) http.Handler
- func CacheControl(opts ...string) func(http.Handler) http.Handler
- func Clickjacking(opt string) func(http.Handler) http.Handler
- func ContentSniffing() func(http.Handler) http.Handler
- func Context(f ContextFunc) func(http.Handler) http.Handler
- func DisallowContentType(contentTypes ...string) func(http.Handler) http.Handler
- func DisallowHTTPHeader(badStatus int, name string, values ...string) func(http.Handler) http.Handler
- func DisallowMethod(methods ...string) func(http.Handler) http.Handler
- func DisallowUserAgent(userAgents ...string) func(http.Handler) http.Handler
- func HSTS(maxAge int, opt string) func(http.Handler) http.Handler
- func NoCache() func(http.Handler) http.Handler
- func RealIP() func(http.Handler) http.Handler
- func Recover(out io.Writer) func(http.Handler) http.Handler
- func RequestHeader(fs ...HeaderFunc) func(http.Handler) http.Handler
- func ResponseHeader(fs ...HeaderFunc) func(http.Handler) http.Handler
- func Timeout(d time.Duration) func(http.Handler) http.Handler
- func Use(middlewares ...func(http.Handler) http.Handler) func(http.Handler) http.Handler
- type ContextFunc
- type HeaderFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowContentType ¶ added in v0.2.0
AllowContentType is middleware that allows a request only if any of the specified strings is included in the Content-Type header. Returns 415 Unsupported Media Type status if the request has a type that is not allowed.
func AllowHTTPHeader ¶
AllowHTTPHeader is middleware that allows a request only when one of the specified strings is included in the specified request header.
func AllowMethod ¶ added in v0.3.0
AllowMethod is a middleware that returns a 405 Method Not Allowed status if the request method is not one of the given methods.
func AllowUserAgent ¶
AllowUserAgent is middleware that allows a request only if any of the specified strings is included in the User-Agent header. Returns 403 Forbidden status if the request has a user-agent that is not allowed.
func CacheControl ¶ added in v0.3.0
CacheControl adds the Cache-Control header.
func Clickjacking ¶ added in v0.2.0
Clickjacking mitigates clickjacking attacks by limiting the display of iframe.
func ContentSniffing ¶ added in v0.2.0
ContentSniffing adds a header for Content-Type sniffing vulnerability countermeasures.
func Context ¶
func Context(f ContextFunc) func(http.Handler) http.Handler
Context is middleware that edits the context of the request.
func DisallowContentType ¶ added in v0.2.0
DisallowContentType is middleware that disallow a request only if any of the specified strings is included in the Content-Type header. Returns 415 Unsupported Media Type status if the request has a type that is not allowed.
func DisallowHTTPHeader ¶
func DisallowHTTPHeader(badStatus int, name string, values ...string) func(http.Handler) http.Handler
DisallowHTTPHeader is middleware that disallows a request only when one of the specified strings is included in the specified request header.
func DisallowMethod ¶ added in v0.3.0
DisallowMethod is a middleware that returns a 405 Method Not Allowed status if the request method is one of the given methods.
func DisallowUserAgent ¶
DisallowUserAgent is middleware that disallow a request only if any of the specified strings is included in the User-Agent header. Returns 403 Forbidden status if the request has a user-agent that is not allowed.
func HSTS ¶ added in v0.2.0
HSTS adds the Strict-Transport-Security header. Proper use of this header will mitigate stripping attacks.
func RealIP ¶ added in v0.3.0
RealIP is middleware that overwrites RemoteAddr of http.Request with X-Forwarded-For or X-Real-IP header. Validation of the X-Forwarded-For header is done from right to left.
func Recover ¶ added in v0.3.0
Recover is a middleware that recovers from panic and records a stack trace and returns a 500 Internal Server Error status.
func RequestHeader ¶ added in v0.2.0
func RequestHeader(fs ...HeaderFunc) func(http.Handler) http.Handler
RequestHeader is middleware that edits the header of the request.
func ResponseHeader ¶ added in v0.2.0
func ResponseHeader(fs ...HeaderFunc) func(http.Handler) http.Handler
ResponseHeader is middleware that edits the header of the response.
Types ¶
type HeaderFunc ¶ added in v0.2.0
HeaderFunc ...
func CacheControlHeaderFunc ¶ added in v0.3.0
func CacheControlHeaderFunc(opts ...string) HeaderFunc
CacheControlHeaderFunc returns a HeaderFunc that adds a Cache-Control header.
func ClickjackingHeaderFunc ¶ added in v0.2.0
func ClickjackingHeaderFunc(opt string) HeaderFunc
ClickjackingHeaderFunc returns a HeaderFunc to mitigate a clickjacking vulnerability.
func ContentSniffingHeaderFunc ¶ added in v0.2.0
func ContentSniffingHeaderFunc() HeaderFunc
ContentSniffingHeaderFunc returns a HeaderFunc for Content-Type sniffing vulnerability countermeasure.
func HSTSHeaderFunc ¶ added in v0.2.0
func HSTSHeaderFunc(maxAge int, opt string) HeaderFunc
HSTSHeaderFunc returns a HeaderFunc that adds a Strict-Transport-Security header.
func NoCacheHeaderFunc ¶ added in v0.3.0
func NoCacheHeaderFunc() HeaderFunc
NoCacheHeaderFunc returns the HeaderFunc to add the Cache-Control header that disables the cache.