http-rs / tide

Fast and friendly HTTP server framework for async Rust
https://docs.rs/tide
Apache License 2.0
5.04k stars 322 forks source link

Fix route in static_file example #906

Closed vijfhoek closed 1 year ago

vijfhoek commented 1 year ago

According to the example, the route should be /src/* but this returns a 404 when going to e.g. http://localhost:8080/dir/Cargo.toml, and even a panic when going to http://localhost:8080/dir/dir/Cargo.toml:

   3: core::option::Option<T>::unwrap
             at /build/rustc-1.68.2-src/library/core/src/option.rs:823:21
   4: <tide::fs::serve_dir::ServeDir as tide::endpoint::Endpoint<State>>::call::{{closure}}
             at /home/sijmen/.cargo/registry/src/github.com-1ecc6299db9ec823/tide-0.16.0/src/fs/serve_dir.rs:30:20

Maybe replacing that unwrap with something more graceful is a good idea too?

vijfhoek commented 1 year ago

I'm dumb, was looking at the main branch while I should've looked at version 0.16.0