tower-http
tower-http copied to clipboard
It's unclear how to hook ServeDir in
I couldn't really figure out how to hook ServeDir in looking at this documentation: https://docs.rs/tower-http/latest/tower_http/services/struct.ServeDir.html
Putting it in my router as a new route() —just like all the other routes— did not work but when I switched it to nest() like the example, it did. I don't really understand why though.
Debugging this was also not very successful.
I'm now trying to vary the base path and running into difficulties again.
Would it be possible to return a custom error page in a DEBUG mode?
tower-http doesn't know anything about axum so I don't think its appropriate for its docs to treat axum with special attention. axum has docs here and here that shows how to use ServeDir. Searching for ServeDir in the axum repo does find the examples. Not sure how to improve that.
Would it be possible to return a custom error page in a DEBUG mode?
I don't think a custom error page is appropriate but we could add some TRACE logging to help people debug issues. What specifically would have helped you debug your issues?
I think a trace of the path being asked for (after being cut up etc.) and then a trace of the file system path being tried would be very helpful here.
Also it would be nice to add the nest() way of hooking this in to the documentation.
I think a trace of the path being asked for (after being cut up etc.) and then a trace of the file system path being tried would be very helpful here.
Sounds good 👍 Do you wanna attempt making a PR?
Also it would be nice to add the
nest()way of hooking this in to the documentation.
Like I mentioned, I don't think its appropriate for tower-https docs to include axum specific examples.
I'll close this for now. You're welcome to submit a PR that adds more logging to ServeDir.