Melora Hugues
c2cc95c238
All checks were successful
continuous-integration/drone/push Build is passing
23 lines
443 B
Go
23 lines
443 B
Go
package middlewares
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
type MiddlewareChains struct {
|
|
handlers []http.Handler
|
|
}
|
|
|
|
func (mc *MiddlewareChains) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
|
for _, h := range mc.handlers {
|
|
h.ServeHTTP(rw, r)
|
|
}
|
|
}
|
|
|
|
func WithLogger(handler http.Handler, l *logrus.Logger) *MiddlewareChains {
|
|
return &MiddlewareChains{
|
|
handlers: []http.Handler{handler, &LoggerMiddleware{l}},
|
|
}
|
|
}
|