Start implementing middleware for logging and authentication in member-console application

This commit is contained in:
2025-02-21 11:22:45 -06:00
parent f0fc18ab7f
commit 0b4cc932b6
2 changed files with 67 additions and 12 deletions

View File

@ -0,0 +1,17 @@
package middleware
import "net/http"
type Middleware func(http.Handler) http.Handler
// CreateStack creates a stack of middleware handlers
func CreateStack(middlewares ...Middleware) Middleware {
return func(nextMiddleware http.Handler) http.Handler {
for i := len(middlewares) - 1; i >= 0; i-- {
currentMiddleware := middlewares[i]
nextMiddleware = currentMiddleware(nextMiddleware)
}
return nextMiddleware
}
}