polycule-connect/polyculeconnect/middlewares/middlewarechain.go
Melora Hugues 55bac84bc2
Some checks failed
continuous-integration/drone Build is failing
Add first basic POC
2023-10-14 18:08:03 +02:00

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}},
}
}