Actually log the endpoint we are serving (#2334)
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.
This commit is contained in:
parent
9b89aa7d2c
commit
d52c13f10f
|
@ -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)
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue