diff --git a/examples/websockets/src/main.rs b/examples/websockets/src/main.rs index 9dab67a0..b221810c 100644 --- a/examples/websockets/src/main.rs +++ b/examples/websockets/src/main.rs @@ -32,19 +32,17 @@ async fn main() { )) .with(tracing_subscriber::fmt::layer()) .init(); - + let assets_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("assets"); // build our application with some routes let app = Router::new() .fallback( - get_service( - ServeDir::new("examples/websockets/assets").append_index_html_on_directories(true), - ) - .handle_error(|error: std::io::Error| async move { - ( - StatusCode::INTERNAL_SERVER_ERROR, - format!("Unhandled internal error: {}", error), - ) - }), + get_service(ServeDir::new(assets_dir).append_index_html_on_directories(true)) + .handle_error(|error: std::io::Error| async move { + ( + StatusCode::INTERNAL_SERVER_ERROR, + format!("Unhandled internal error: {}", error), + ) + }), ) // routes are matched from bottom to top, so we have to put `nest` at the // top since it matches all routes