Skip to content

fix(middleware): apply PathRewrite to existing routing paths - #1201

Open
sergioperezcheco wants to merge 1 commit into
go-chi:masterfrom
sergioperezcheco:fix/path-rewrite-mounted-20261003-140100
Open

sergioperezcheco wants to merge 1 commit into
go-chi:masterfrom
sergioperezcheco:fix/path-rewrite-mounted-20261003-140100

Conversation

@sergioperezcheco

Copy link
Copy Markdown

PathRewrite updates URL.Path, but mounted routers and preceding middleware such as URLFormat can already have set RoutePath. Routing then continues with the unchanged path and rewritten requests return 404.

Rewrite an existing RoutePath independently while preserving the original first replacement in URL.Path. The routing path remains relative to its mount point, and the godoc explains where full-path rewrites belong. Regression tests exercise mounted and nested routers, encoded parameters, repeated matches, URLFormat composition, and full-path middleware placement.

The regressions fail against the original implementation. go test -race -count=1 ./..., go vet ./..., and goimports pass locally on Go 1.26.4/macOS arm64; the other Go versions and operating systems in CI have not been run locally.

Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
Signed-off-by: sergioperezcheco <checo520@outlook.com>

This branch has not been deployed

No deployments
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.

1 participant