Removes pkg/middleware. The Logger, Recoverer, and RealIP middlewares now live in the sibling lightmux-contrib module as the realip, requestlog, and recoverer packages, each exposing a single New(...) constructor. The Middleware type alias moves to pkg/router. The splinter dependency is dropped from go.mod; only errx remains. BREAKING CHANGE: consumers must replace pkg/middleware imports with the corresponding lightmux-contrib sub-packages. See README for the new usage. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
15 lines
443 B
Go
15 lines
443 B
Go
package router
|
|
|
|
import "net/http"
|
|
|
|
// chain wraps h with groupMws followed by routeMws so that groupMws[0] is the
|
|
// outermost layer (runs first on request, last on response).
|
|
func chain(h http.Handler, groupMws, routeMws []Middleware) http.Handler {
|
|
all := make([]Middleware, 0, len(groupMws)+len(routeMws))
|
|
all = append(all, groupMws...)
|
|
all = append(all, routeMws...)
|
|
for i := len(all) - 1; i >= 0; i-- {
|
|
h = all[i](h)
|
|
}
|
|
return h
|
|
}
|