MCPcopy Index your code
hub / github.com/unrolled/secure / Handler

Method Handler

secure.go:201–215  ·  view source on GitHub ↗

Handler implements the http.HandlerFunc for integration with the standard net/http lib.

(h http.Handler)

Source from the content-addressed store, hash-verified

199
200// Handler implements the http.HandlerFunc for integration with the standard net/http lib.
201func (s *Secure) Handler(h http.Handler) http.Handler {
202 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
203 // Let secure process the request. If it returns an error,
204 // that indicates the request should not continue.
205 responseHeader, r, err := s.processRequest(w, r)
206 addResponseHeaders(responseHeader, w)
207
208 // If there was an error, do not continue.
209 if err != nil {
210 return
211 }
212
213 h.ServeHTTP(w, r)
214 })
215}
216
217// HandlerForRequestOnly implements the http.HandlerFunc for integration with the standard net/http lib.
218// Note that this is for requests only and will not write any headers.

Callers 15

TestNoConfigFunction · 0.80
TestNoAllowHostsFunction · 0.80
TestGoodSingleAllowHostsFunction · 0.80
TestBadSingleAllowHostsFunction · 0.80
TestAllowHostsInDevModeFunction · 0.80

Calls 2

processRequestMethod · 0.95
addResponseHeadersFunction · 0.85

Tested by 15

TestNoConfigFunction · 0.64
TestNoAllowHostsFunction · 0.64
TestGoodSingleAllowHostsFunction · 0.64
TestBadSingleAllowHostsFunction · 0.64
TestAllowHostsInDevModeFunction · 0.64