Update for the PR feedback

This commit is contained in:
Philibert Dugas 2016-09-22 13:30:04 -04:00
parent 9c2705a5a2
commit b557acf987
No known key found for this signature in database
GPG Key ID: 3907E2E57F97F72C

View File

@ -141,9 +141,10 @@ func RecoverPanics(handler http.Handler, resolver *RequestInfoResolver) http.Han
glog.Errorf("APIServer panic'd on %v %v: %v\n%s\n", req.Method, req.RequestURI, err, debug.Stack()) glog.Errorf("APIServer panic'd on %v %v: %v\n%s\n", req.Method, req.RequestURI, err, debug.Stack())
}) })
logger := httplog.NewLogged(req, &w)
requestInfo, err := resolver.GetRequestInfo(req) requestInfo, err := resolver.GetRequestInfo(req)
if err != nil || requestInfo.Verb != "proxy" { if err != nil || requestInfo.Verb != "proxy" {
defer httplog.NewLogged(req, &w).StacktraceWhen( logger.StacktraceWhen(
httplog.StatusIsNot( httplog.StatusIsNot(
http.StatusOK, http.StatusOK,
http.StatusCreated, http.StatusCreated,
@ -159,8 +160,9 @@ func RecoverPanics(handler http.Handler, resolver *RequestInfoResolver) http.Han
errors.StatusUnprocessableEntity, errors.StatusUnprocessableEntity,
http.StatusSwitchingProtocols, http.StatusSwitchingProtocols,
), ),
).Log() )
} }
defer logger.Log()
// Dispatch to the internal handler // Dispatch to the internal handler
handler.ServeHTTP(w, req) handler.ServeHTTP(w, req)
}) })