diff --git a/examples/static-file-server/src/main.rs b/examples/static-file-server/src/main.rs index 3aa7a9a8fe..707d2ee3f3 100644 --- a/examples/static-file-server/src/main.rs +++ b/examples/static-file-server/src/main.rs @@ -32,6 +32,7 @@ async fn main() { serve(using_serve_dir_with_handler_as_service(), 3004), serve(two_serve_dirs(), 3005), serve(calling_serve_dir_from_a_handler(), 3006), + serve(using_serve_file_from_a_route(), 3307), ); } @@ -101,6 +102,10 @@ fn calling_serve_dir_from_a_handler() -> Router { ) } +fn using_serve_file_from_a_route() -> Router { + Router::new().route_service("/foo", ServeFile::new("assets/index.html")) +} + async fn serve(app: Router, port: u16) { let addr = SocketAddr::from(([127, 0, 0, 1], port)); let listener = tokio::net::TcpListener::bind(addr).await.unwrap();