Making tower-http's ServeDir fall back to axum::Router #3206
Unanswered
utkarshkukreti
asked this question in
Q&A
Replies: 1 comment 1 reply
-
You can try looking at #3202, or more specifically just calling |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
I'm trying to combine tower-http's ServeDir and axum's Router in such a way that if a static file exists, it should be served, otherwise the request should be passed to the axum Router. Here's what I have so far:
With this, I expect to get the contents of
src/main.rs
if I doGET /main.rs
and getHello, World!
if I doGET /something-else.rs
.This fails to compile:
I have tried many variations of this but could not get any to compile. Doing it the other way, where axum's Router falls back to ServeDir works fine, but I want the static files to be served first.
Any pointers?
axum version
0.8.1
Beta Was this translation helpful? Give feedback.
All reactions