Skip to content

Commit

Permalink
Actually log the endpoint we are serving (#2334)
Browse files Browse the repository at this point in the history
We use `http.StripPrefix` so handlers don't have to deal with stripping the boring part of URLs that they don't need (#1881). This caused either an empty string or only the ID from the path to be logged as the `endpoint` which was not useful for debugging. By doing the logging in the constructor instead we still have access to the prefix part of the path and can use it to reconstruct the full path.

Fixes #2328.
  • Loading branch information
Roland Bracewell Shoemaker authored and cpu committed Nov 19, 2016
1 parent 9b89aa7 commit d52c13f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 0 additions & 3 deletions wfe/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ func (th *topHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Extra: make(map[string]interface{}, 0),
}
w.Header().Set("Boulder-Request-ID", logEvent.ID)
if r.URL != nil {
logEvent.Endpoint = r.URL.String()
}
defer th.logEvent(logEvent)

th.wfe.ServeHTTP(logEvent, w, r)
Expand Down
6 changes: 6 additions & 0 deletions wfe/wfe.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"net"
"net/http"
"net/url"
"path"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -155,6 +156,11 @@ func (wfe *WebFrontEndImpl) HandleFunc(mux *http.ServeMux, pattern string, h wfe
logEvent.AddError("unable to make nonce: %s", err)
}

logEvent.Endpoint = pattern
if request.URL != nil {
logEvent.Endpoint = path.Join(logEvent.Endpoint, request.URL.Path)
}

switch request.Method {
case "HEAD":
// Go's net/http (and httptest) servers will strip out the body
Expand Down

0 comments on commit d52c13f

Please sign in to comment.