Skip to main content

rewrite_legacy_uri

Function rewrite_legacy_uri 

Source
pub(crate) fn rewrite_legacy_uri(req: Request) -> Request
Expand description

Tide-disco served every v1 module at both /<module>/... and /v1/<module>/..., and legacy clients (surf-disco, the light-client, tests) still address the unversioned and /v0 forms. Axum only declares the /v1/... and /v2/... route shapes, and Router::layer middleware runs after routing, so it can never redirect a request onto a route it doesn’t already match. This function is instead wrapped around the whole router with tower::util::MapRequestLayer (see serve_axum), which runs before routing, to rewrite the URI so the declared routes match.

Excludes paths that are intentionally unversioned: /, /healthcheck, /version, and anything already prefixed with /v1 or /v2.