Handler implements the http.HandlerFunc for integration with the standard net/http lib.
(h http.Handler)
| 199 | |
| 200 | // Handler implements the http.HandlerFunc for integration with the standard net/http lib. |
| 201 | func (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. |