mirror of
https://github.com/tokio-rs/axum.git
synced 2025-04-26 13:56:22 +02:00
Fix missing assets in websockets example (#1089)
* fix missing assets running websockets example * Update examples/websockets/src/main.rs Co-authored-by: David Pedersen <david.pdrsn@gmail.com> * remove unnecessary mut * fix cargo fmt Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
This commit is contained in:
parent
ad67289226
commit
cbb2e8a244
1 changed files with 8 additions and 10 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue