Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix(server): let the mux bind path values for a matched route behind the not-found envelope (PIN-366)

Luigi Agosti122c525131e0
diff --git a/internal/server/notfound.go b/internal/server/notfound.go
index d9b679ef..9a5f5fbf 100644
--- a/internal/server/notfound.go
+++ b/internal/server/notfound.go
@@ -18,7 +18,7 @@ func notFoundEnvelope(mux *http.ServeMux) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
matched, pattern := mux.Handler(r)
if pattern != "" {
- matched.ServeHTTP(w, r)
+ mux.ServeHTTP(w, r)
return
}
diff --git a/internal/server/notfound_test.go b/internal/server/notfound_test.go
index ec603d54..5116a6d6 100644
--- a/internal/server/notfound_test.go
+++ b/internal/server/notfound_test.go
@@ -136,3 +136,18 @@ func TestWrongMethodStaysA405Envelope(t *testing.T) {
t.Errorf("code = %q, want method_not_allowed", code)
}
}
+
+func TestAMatchedWildcardRouteSeesItsPathValue(t *testing.T) {
+ mux := http.NewServeMux()
+ var seen string
+ mux.HandleFunc("GET /tabs/{id}/snapshot", func(_ http.ResponseWriter, r *http.Request) {
+ seen = r.PathValue("id")
+ })
+
+ w := httptest.NewRecorder()
+ notFoundEnvelope(mux).ServeHTTP(w, httptest.NewRequest(http.MethodGet, "/tabs/DEADBEEF/snapshot", nil))
+
+ if seen != "DEADBEEF" {
+ t.Fatalf("handler saw PathValue(\"id\") = %q through the envelope, want %q; every /tabs/{id} route would answer 'tab id required'", seen, "DEADBEEF")
+ }
+}