polycule-connect/polyculeconnect/middlewares/middlewarechain.go
Melora Hugues 4507728dae
All checks were successful
continuous-integration/drone/push Build is passing
Add first basic POC
2023-10-14 18:28:01 +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}},
}
}