Skip to content

fix: preserve URL params after middleware path rewrite - #3

Open
jearthliu wants to merge 1 commit into
madalynerlge2:mainfrom
jearthliu:fix/preserve-url-params-after-path-rewrite
Open

fix: preserve URL params after middleware path rewrite#3
jearthliu wants to merge 1 commit into
madalynerlge2:mainfrom
jearthliu:fix/preserve-url-params-after-path-rewrite

Conversation

@jearthliu

Copy link
Copy Markdown

When middleware modifies r.URL.Path (for prefix stripping or path rewriting), chi caches RoutePath during initial routing. If RoutePath is not updated to match the new path, downstream handlers return empty strings from URLParam().

This fix updates RouteContext.RoutePath alongside r.URL.Path so URL parameters are resolved against the rewritten path. Closes #1.

When middleware modifies r.URL.Path, update RoutePath so
downstream handlers resolve URL parameters against the
rewritten path. Closes madalynerlge2#1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🎯 Fix URL Parameter Loss When Request.URL.Path is Rewritten by Middleware

1 participant