mirror of
https://github.com/tokio-rs/axum.git
synced 2024-11-22 15:17:18 +01:00
Fix static file serving in examples (#10)
This commit is contained in:
parent
04d62798b6
commit
7a051eb2d0
1 changed files with 10 additions and 3 deletions
|
@ -29,9 +29,16 @@ async fn main() {
|
||||||
// build our application with some routes
|
// build our application with some routes
|
||||||
let app = nest(
|
let app = nest(
|
||||||
"/",
|
"/",
|
||||||
ServeDir::new("examples/websocket")
|
tower_web::service::get(
|
||||||
.append_index_html_on_directories(true)
|
ServeDir::new("examples/websocket")
|
||||||
.handle_error(|error| (StatusCode::INTERNAL_SERVER_ERROR, error.to_string())),
|
.append_index_html_on_directories(true)
|
||||||
|
.handle_error(|error: std::io::Error| {
|
||||||
|
(
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
|
format!("Unhandled interal error: {}", error),
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
// routes are matched from bottom to top, so we have to put `nest` at the
|
// routes are matched from bottom to top, so we have to put `nest` at the
|
||||||
// top since it matches all routes
|
// top since it matches all routes
|
||||||
|
|
Loading…
Reference in a new issue