extract middlewares to lightmux-contrib
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>
This commit is contained in:
parent
d983cca25e
commit
22277186ae
15 changed files with 44 additions and 612 deletions
|
|
@ -5,11 +5,9 @@ import (
|
|||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.juancwu.dev/juancwu/lightmux/pkg/middleware"
|
||||
)
|
||||
|
||||
func tagMW(log *[]string, tag string) middleware.Middleware {
|
||||
func tagMW(log *[]string, tag string) Middleware {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
*log = append(*log, tag+":before")
|
||||
|
|
@ -26,8 +24,8 @@ func TestChainOrder(t *testing.T) {
|
|||
})
|
||||
|
||||
wrapped := chain(h,
|
||||
[]middleware.Middleware{tagMW(&log, "g1"), tagMW(&log, "g2")},
|
||||
[]middleware.Middleware{tagMW(&log, "r1"), tagMW(&log, "r2")},
|
||||
[]Middleware{tagMW(&log, "g1"), tagMW(&log, "g2")},
|
||||
[]Middleware{tagMW(&log, "r1"), tagMW(&log, "r2")},
|
||||
)
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/", nil)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue