// ServeHTTP encapsulates the call to underlying Handler to handle the request // and return the response with proper HTTP status code func (h HttpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { var err error // Throw 405 when requested with an unsupported verb. if r.Method != h.Method { err = errors.NewMethodNotAllowed(r.Method) } else { err = h.Handle(w, r) } status := handleError(w, err) log.Infof("%s - \"%s %s\" %d", r.RemoteAddr, r.Method, r.URL, status) }
// ServeHTTP encapsulates the call to underlying Handler to handle the request // and return the response with proper HTTP status code func (h HTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { var err error var match bool // Throw 405 when requested with an unsupported verb. for _, m := range h.Methods { if m == r.Method { match = true } } if match { err = h.Handle(w, r) } else { err = errors.NewMethodNotAllowed(r.Method) } status := HandleError(w, err) log.Infof("%s - \"%s %s\" %d", r.RemoteAddr, r.Method, r.URL, status) }