5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-04 09:21:44 +08:00
wails/v3/internal/assetserver/middleware.go
2023-08-14 08:31:55 +10:00

21 lines
592 B
Go

package assetserver
import (
"net/http"
)
// Middleware defines a HTTP middleware that can be applied to the AssetServer.
// The handler passed as next is the next handler in the chain. One can decide to call the next handler
// or implement a specialized handling.
type Middleware func(next http.Handler) http.Handler
// ChainMiddleware allows chaining multiple middlewares to one middleware.
func ChainMiddleware(middleware ...Middleware) Middleware {
return func(h http.Handler) http.Handler {
for i := len(middleware) - 1; i >= 0; i-- {
h = middleware[i](h)
}
return h
}
}