fix(middleware): define middleware in a more streamlined way
All checks were successful
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 2m26s

This commit was merged in pull request #270.
This commit is contained in:
2024-11-20 09:49:48 +01:00
committed by Tim Wundenberg
parent 003ccbe035
commit 9ab78b6cc8
5 changed files with 33 additions and 13 deletions

13
middleware/wrapper.go Normal file
View File

@@ -0,0 +1,13 @@
package middleware
import "net/http"
func Wrapper(next http.Handler, handlers ...func(http.Handler) http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
lastHandler := next
for i := len(handlers) - 1; i >= 0; i-- {
lastHandler = handlers[i](lastHandler)
}
lastHandler.ServeHTTP(w, r)
})
}