aide icon indicating copy to clipboard operation
aide copied to clipboard

Bug: ApiRouter::nest_api_service() automatically applies trailing slash removal

Open baxterjo opened this issue 1 month ago • 1 comments

When nesting routers within routers using ApiRouter::nest_api_service() the resulting router automatically and implicitly trims trailing slashes from the nested routes. This happens without the axum-extra feature, which contains the ApiRouter::api_route_with_tsr() method.

I'm not really complaining because this behavior was welcome in my use case. But it did lead to a footgun with tower_http::NormalizePath layer.

I thought I had implemented route normalization manually with the above layer, but when I later moved one of my endpoints out of the service being nested with nest_api_service() the associated test started failing and I wasn't sure why.

It took a bit of investigating to realize that I had done nothing with NormalizePath layer and that I needed to use the api_route_with_tsr() when adding paths one by one to the root router.

baxterjo avatar Dec 01 '25 22:12 baxterjo