Fix static file serving in examples (#10)

This commit is contained in:
David Pedersen 2021-06-13 00:17:17 +02:00 committed by GitHub
parent 04d62798b6
commit 7a051eb2d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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(
"/", "/",
tower_web::service::get(
ServeDir::new("examples/websocket") ServeDir::new("examples/websocket")
.append_index_html_on_directories(true) .append_index_html_on_directories(true)
.handle_error(|error| (StatusCode::INTERNAL_SERVER_ERROR, error.to_string())), .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