From 7a051eb2d01a1fbf25a8bfeeab795003148e3f01 Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Sun, 13 Jun 2021 00:17:17 +0200 Subject: [PATCH] Fix static file serving in examples (#10) --- examples/websocket.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/examples/websocket.rs b/examples/websocket.rs index 73b5fa1d..4db23a2a 100644 --- a/examples/websocket.rs +++ b/examples/websocket.rs @@ -29,9 +29,16 @@ async fn main() { // build our application with some routes let app = nest( "/", - ServeDir::new("examples/websocket") - .append_index_html_on_directories(true) - .handle_error(|error| (StatusCode::INTERNAL_SERVER_ERROR, error.to_string())), + tower_web::service::get( + ServeDir::new("examples/websocket") + .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 // top since it matches all routes