portal/api/middleware/util.go

15 lines
330 B
Go
Raw Normal View History

2024-01-19 22:11:16 +00:00
package middleware
import (
"git.lumeweb.com/LumeWeb/portal/api"
"go.sia.tech/jape"
)
func ApplyMiddlewares(handler jape.Handler, middlewares ...api.MiddlewareFunc) jape.Handler {
// Apply each middleware in reverse order
for i := len(middlewares) - 1; i >= 0; i-- {
handler = middlewares[i](handler)
}
return handler
}