Documentation ¶
Index ¶
- func GZIPHandler(h http.Handler, filterFn func(http.ResponseWriter, *http.Request) bool) http.HandlerFunc
- func GZIPHandlerFunc(h http.HandlerFunc, filterFn func(http.ResponseWriter, *http.Request) bool) http.HandlerFunc
- func GetResponseWriter(w http.ResponseWriter, predicate func(http.ResponseWriter) bool) (http.ResponseWriter, bool)
- func HeaderMatch(hdr http.Header, nm string, matchType HeaderMatchType, test string) bool
- type HeaderMatchType
- type WrapWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GZIPHandler ¶
func GZIPHandler(h http.Handler, filterFn func(http.ResponseWriter, *http.Request) bool) http.HandlerFunc
Gzip compression HTTP handler. If the client supports it, it compresses the response written by the wrapped handler. The filter function is called when the response is about to be written to determine if compression should be applied. If this argument is nil, the default filter will GZIP only content types containing /json|text|javascript/.
func GZIPHandlerFunc ¶
func GZIPHandlerFunc(h http.HandlerFunc, filterFn func(http.ResponseWriter, *http.Request) bool) http.HandlerFunc
GZIPHandlerFunc is the same as GZIPHandler, it is just a convenience signature that accepts a func(http.ResponseWriter, *http.Request) instead of a http.Handler interface. It saves the boilerplate http.HandlerFunc() cast.
func GetResponseWriter ¶
func GetResponseWriter(w http.ResponseWriter, predicate func(http.ResponseWriter) bool) (http.ResponseWriter, bool)
Helper function to retrieve a specific ResponseWriter.
func HeaderMatch ¶
Check if the specified header matches the test string, applying the header match type specified.
Types ¶
type HeaderMatchType ¶
type HeaderMatchType int
Kind of match to apply to the header check.
const ( HmEquals HeaderMatchType = iota HmStartsWith HmEndsWith HmContains )
type WrapWriter ¶
type WrapWriter interface { http.ResponseWriter WrappedWriter() http.ResponseWriter }
This interface can be implemented by an augmented ResponseWriter, so that it doesn't hide other augmented writers in the chain.