Documentation
¶
Index ¶
- Variables
- func AllowedHosts(allowed_hosts ...string) func(next mux.Handler) mux.Handler
- func AllowedHostsFunc(allowed_hosts []string, ...) func(next mux.Handler) mux.Handler
- func BufferMiddleware(newFn func(w http.ResponseWriter, r *http.Request) http.ResponseWriter) mux.Middleware
- func Cache(maxAge int) func(next mux.Handler) mux.Handler
- func GZIP(next mux.Handler) mux.Handler
- func NewBufferedWriter(w http.ResponseWriter) http.ResponseWriter
- func NoCache(next mux.Handler) mux.Handler
- func Recoverer(onError func(err error, w http.ResponseWriter, r *http.Request)) mux.Middlewaredeprecated
- func XFrameOptions(options XFrameOption) mux.Middleware
- type BufferedResponse
- type Logger
- type RecovererMiddleware
- type XFrameOption
Constants ¶
This section is empty.
Variables ¶
var DefaultLogger = &Logger{ Output: os.Stdout, }
Functions ¶
func AllowedHosts ¶
Check if the request.Host is in the allowed hosts list
func AllowedHostsFunc ¶ added in v1.6.0
func AllowedHostsFunc(allowed_hosts []string, notAllowed func(w http.ResponseWriter, r *http.Request, host string)) func(next mux.Handler) mux.Handler
Check if the request.Host is in the allowed hosts list
notAllowed is called when the host is not allowed.
func BufferMiddleware ¶ added in v1.6.0
func BufferMiddleware(newFn func(w http.ResponseWriter, r *http.Request) http.ResponseWriter) mux.Middleware
func Cache ¶
Set the cache headers for the response. This will enable caching for the specified amount of seconds.
func NewBufferedWriter ¶ added in v1.6.1
func NewBufferedWriter(w http.ResponseWriter) http.ResponseWriter
func Recoverer
deprecated
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.
Deprecated: Use RecovererMiddleware struct type instead.
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 BufferedResponse ¶ added in v1.6.0
type BufferedResponse interface {
http.ResponseWriter
FlushBuffer()
}
type RecovererMiddleware ¶ added in v1.6.1
type RecovererMiddleware struct {
Next func(next mux.Handler, w http.ResponseWriter, r *http.Request)
Error func(err error, w http.ResponseWriter, r *http.Request)
}
func (*RecovererMiddleware) Handle ¶ added in v1.6.1
func (rm *RecovererMiddleware) Handle(next mux.Handler) mux.Handler
func (*RecovererMiddleware) HandleError ¶ added in v1.6.1
func (rm *RecovererMiddleware) HandleError(err error, w http.ResponseWriter, r *http.Request)
func (*RecovererMiddleware) HandleNext ¶ added in v1.6.1
func (rm *RecovererMiddleware) HandleNext(next mux.Handler, w http.ResponseWriter, r *http.Request)
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" )