Initial update - manage access log

This commit is contained in:
David Tootill 2016-04-19 16:45:59 -07:00
parent a6c5e85ae7
commit 10815eca8e
10 changed files with 604 additions and 11 deletions

View file

@ -0,0 +1,24 @@
package middlewares
/*
Middleware saveBackend sends the backend name to the logger.
*/
import (
"net/http"
)
// SaveBackend holds the next handler
type SaveBackend struct {
next http.Handler
}
// NewSaveBackend creates a SaveBackend
func NewSaveBackend(next http.Handler) *SaveBackend {
return &SaveBackend{next}
}
func (sb *SaveBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
saveBackendNameForLogger(r, (*r.URL).String())
sb.next.ServeHTTP(rw, r)
}