Skip to content

Commit

Permalink
Fix missing assets in websockets example (#1089)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
yshing and davidpdrsn committed Jun 15, 2022
1 parent ad67289 commit cbb2e8a
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions examples/websockets/src/main.rs
Expand Up @@ -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
Expand Down

0 comments on commit cbb2e8a

Please sign in to comment.