-
Couldn't load subscription status.
- Fork 332
Open
Description
A tiny sample project. I have
/src/main.rs
/static/index.html
/static/favicon.jpg
where main.rs is roughly this:
#[async_std::main]
async fn main() -> Result<(), std::io::Error> {
tracing_subscriber::fmt()
.with_max_level(tracing::Level::TRACE)
.init();
let mut app = tide::new();
app.with(tide_tracing::TraceMiddleware::new());
app.at("/*")
.serve_dir("/home/me/foo/static/")?;
app.at("/api").nest({
let mut api = tide::new();
api.at("/hello").get(|_| async { Ok("Hello, world") });
api.at("/goodbye").get(|_| async { Ok("Goodbye, world") });
api
});
app.listen("127.0.0.1:8080").await?;
Ok(())
}I tried serve_dir both with the absolute path (above) or (preferably) with a relative one. In both cases it doesn't work as expected (I expect / to serve /static/index.html and /favicon.jpg to resolve the same way).
I would instead get something like this:
2023-05-01T04:52:48.658475Z INFO tide::log::middleware: <-- Request received
2023-05-01T04:52:48.658572Z INFO Request{http.method=GET http.target=/}: tide_tracing: received
2023-05-01T04:52:48.658649Z WARN Request{http.method=GET http.target=/}:Response{http.status_code=404 http.duration=41.377µs}:Client error: tide_tracing: sent
2023-05-01T04:52:48.658699Z WARN tide::log::middleware: Client error --> Response sent
Whatever I try, tide just returns a 404 - which doesn't make sense to me at all. Worse though: While experimenting and trying to figure out what's going on, I stumbled upon this: Requesting /static/index.html causes a panic and a 500 handling the request, which is arguably worse than the confusing 404:
2023-05-01T04:53:02.376075Z INFO tide::log::middleware: <-- Request received
2023-05-01T04:53:02.376098Z INFO Request{http.method=GET http.target=/static/index.html}: tide_tracing: received
thread 'async-std/runtime' panicked at 'called `Option::unwrap()` on a `None` value', /home/bam/.cargo/registry/src/github.com-1ecc6299db9ec823/tide-0.16.0/src/fs/serve_dir.rs:28:52
Metadata
Metadata
Assignees
Labels
No labels