Skip to content

how to call fallback when .nest_service does not match #2791

Answered by mladedav
cppcoffee asked this question in Q&A
Discussion options

You must be logged in to vote

You can use something like this:

    let serve_dir = ServeDir::new("assets").not_found_service(ServeFile::new("assets/index.html"));

It's one of the examples in examples/static-file-server.

The issue is that the router matches the nested service (which itself acts as a Router) and it is then responsible for setting fallbacks and such.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@cppcoffee
Comment options

Answer selected by cppcoffee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants