ServeHTTP encapsulates the call to underlying Handler to handle the request and return the response with proper HTTP status code
(w http.ResponseWriter, r *http.Request)
| 69 | // ServeHTTP encapsulates the call to underlying Handler to handle the request |
| 70 | // and return the response with proper HTTP status code |
| 71 | func (h HTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
| 72 | var err error |
| 73 | var match bool |
| 74 | // Throw 405 when requested with an unsupported verb. |
| 75 | for _, m := range h.Methods { |
| 76 | if m == r.Method { |
| 77 | match = true |
| 78 | } |
| 79 | } |
| 80 | if match { |
| 81 | err = h.Handle(w, r) |
| 82 | } else { |
| 83 | err = errors.NewMethodNotAllowed(r.Method) |
| 84 | } |
| 85 | status := HandleError(w, err) |
| 86 | log.Infof("%s - \"%s %s\" %d", r.RemoteAddr, r.Method, r.URL, status) |
| 87 | } |
| 88 | |
| 89 | // readRequestBlob takes a JSON-blob-encoded response body in the form |
| 90 | // map[string]string and returns it, the list of keywords presented, |
no test coverage detected