Minor beautification

This commit is contained in:
Richard Barnes 2015-10-21 09:25:27 -04:00
parent dc58017032
commit d61d09bb61
2 changed files with 12 additions and 12 deletions

View File

@ -40,13 +40,13 @@ type wfeHandler interface {
ServeHTTP(e *requestEvent, w http.ResponseWriter, r *http.Request)
}
type wfeTopHandler struct {
h wfeHandler
type topHandler struct {
wfe wfeHandler
log *blog.AuditLogger
clk clock.Clock
}
func (t *wfeTopHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
func (th *topHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
logEvent := &requestEvent{
ID: core.NewToken(),
ClientAddr: getClientAddr(r),
@ -57,20 +57,20 @@ func (t *wfeTopHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.URL != nil {
logEvent.Path = r.URL.String()
}
defer t.logEvent(logEvent)
defer th.logEvent(logEvent)
t.h.ServeHTTP(logEvent, w, r)
th.wfe.ServeHTTP(logEvent, w, r)
}
func (t *wfeTopHandler) logEvent(logEvent *requestEvent) {
logEvent.ResponseTime = t.clk.Now()
func (th *topHandler) logEvent(logEvent *requestEvent) {
logEvent.ResponseTime = th.clk.Now()
var msg string
if len(logEvent.Errors) != 0 {
msg = "Terminated request"
} else {
msg = "Successful request"
}
t.log.InfoObject(msg, logEvent)
th.log.InfoObject(msg, logEvent)
}
// Comma-separated list of HTTP clients involved in making this request,

View File

@ -172,10 +172,10 @@ func (wfe *WebFrontEndImpl) HandleFunc(mux *http.ServeMux, pattern string, h wfe
methodsMap["HEAD"] = true
}
methodsStr := strings.Join(methods, ", ")
mux.Handle(pattern, &wfeTopHandler{
mux.Handle(pattern, &topHandler{
log: wfe.log,
clk: clock.Default(),
h: wfeHandlerFunc(func(logEvent *requestEvent, response http.ResponseWriter, request *http.Request) {
wfe: wfeHandlerFunc(func(logEvent *requestEvent, response http.ResponseWriter, request *http.Request) {
// We do not propagate errors here, because (1) they should be
// transient, and (2) they fail closed.
nonce, err := wfe.nonceService.Nonce()
@ -249,10 +249,10 @@ func (wfe *WebFrontEndImpl) Handler() (http.Handler, error) {
// We don't use our special HandleFunc for "/" because it matches everything,
// meaning we can wind up returning 405 when we mean to return 404. See
// https://github.com/letsencrypt/boulder/issues/717
m.Handle("/", &wfeTopHandler{
m.Handle("/", &topHandler{
log: wfe.log,
clk: clock.Default(),
h: wfeHandlerFunc(wfe.Index),
wfe: wfeHandlerFunc(wfe.Index),
})
return m, nil
}