feat(smalltrip,multiplexer): form method multiplexer

This commit is contained in:
Guz
2025-08-08 19:17:57 -03:00
parent ec99bf0d02
commit 0d29f470d3

View File

@@ -0,0 +1,22 @@
package multiplexer
import (
"net/http"
"strings"
)
func WithFormMethod(mux Multiplexer, key string) Multiplexer {
return &formMethodMux{key: key, Multiplexer: mux}
}
type formMethodMux struct {
key string
Multiplexer
}
func (mux *formMethodMux) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if v := r.FormValue(mux.key); v != "" {
r.Method = strings.ToUpper(v)
}
mux.Multiplexer.ServeHTTP(w, r)
}