traefik/middlewares/saveBackend.go

21 lines
422 B
Go
Raw Normal View History

2016-04-19 23:45:59 +00:00
package middlewares
import (
"net/http"
)
2016-04-28 11:00:38 +00:00
// SaveBackend sends the backend name to the logger.
2016-04-19 23:45:59 +00:00
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)
}