axum icon indicating copy to clipboard operation
axum copied to clipboard

Fallback handlers on nested routers returning 404

Open maxburke opened this issue 2 years ago • 5 comments

I'm trying to do an upgrade from axum-0.6.11 to axum-0.6.20 and I noticed that the behavior we were relying on in 0.6.11, where a nested handler could designate a fallback, seems to not work in 0.6.20.

I've got a test case in this repository:

https://github.com/maxburke/axum-test

With axum-0.6.11, curl -v http://localhost:3000/nest/ returns 200 + "Hello World", but with axum-0.6.20, the same curl command returns 404 + empty response.

maxburke avatar Oct 04 '23 20:10 maxburke

Does that code even compile? (can't check, on mobile) That example code passes a MethodRouter instead of a handler function to fallback.

jplatte avatar Oct 04 '23 21:10 jplatte

Yup, it compiles. Changing the fallback to .fallback(root_handler) gives the same result.

maxburke avatar Oct 04 '23 21:10 maxburke

I have independently reproduced this.

Protryon avatar Nov 14 '23 16:11 Protryon

@Protryon do you wanna share your repro or is it secret? 😅

davidpdrsn avatar Nov 14 '23 16:11 davidpdrsn

@Protryon do you wanna share your repro or is it secret? 😅

It's not public, but the TL;DR was a nested router that had a route for / and /*var pointing to the same routes. GET /xyz and GET /xyz/t worked, but GET /xyz/ didn't. I reverted to 0.6.11, and it fixed itself. Fallbacks similarly didn't work for this use case, but worked in 0.6.11.

Protryon avatar Nov 14 '23 23:11 Protryon