This commit is contained in:
rl544
2026-09-15 01:38:15 +09:00
parent e748221831
commit 4e8a65f40d
16 changed files with 906 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
package middleware
import "net/http"
// Middleware defines a function that wraps an http.Handler
type Middleware func(http.Handler) http.Handler
// Chain constructs a new http.Handler by chaining multiple Middlewares around a final http.Handler
func Chain(handler http.Handler, middlewares ...Middleware) http.Handler {
// Loop in reverse to preserve the order of execution
for i := len(middlewares) - 1; i >= 0; i-- {
handler = middlewares[i](handler)
}
return handler
}