Documentation ¶
Index ¶
- func AllowedHosts(allowed_hosts ...string) func(next mux.Handler) mux.Handler
- func Cache(maxAge int) func(next mux.Handler) mux.Handler
- func GZIP(next mux.Handler) mux.Handler
- func NoCache(next mux.Handler) mux.Handler
- func Recoverer(onError func(err error, w http.ResponseWriter, r *http.Request)) mux.Middleware
- func XFrameOptions(options XFrameOption) mux.Middleware
- type XFrameOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowedHosts ¶
Check if the request.Host is in the allowed hosts list
func Cache ¶
Set the cache headers for the response. This will enable caching for the specified amount of seconds.
func Recoverer ¶
func Recoverer(onError func(err error, w http.ResponseWriter, r *http.Request)) mux.Middleware
Recoverer recovers from panics and logs the error, if the logger was set.
func XFrameOptions ¶
func XFrameOptions(options XFrameOption) mux.Middleware
X-Frame-Options is a header that can be used to indicate whether or not a browser should be allowed to render a page in a <frame>, <iframe> or <object>.
Sites can use this to avoid clickjacking attacks, by ensuring that their content is not embedded into other sites.
Types ¶
type XFrameOption ¶
type XFrameOption string
XFrameOption is the type for the XFrameOptions middleware.
const ( // XFrameDeny is the most restrictive option, and it tells the browser to not display the content in an iframe. XFrameDeny XFrameOption = "DENY" // XFrameSame is the default value for XFrameOptions. XFrameSame XFrameOption = "SAMEORIGIN" // XFrameAllow is a special case, and it should not be used. // It is obsolete and is only here for backwards compatibility. XFrameAllow XFrameOption = "ALLOW-FROM" )
Click to show internal directories.
Click to hide internal directories.