diff --git a/src/fileserv.rs b/src/fileserv.rs
index acc1635..e266d2c 100644
--- a/src/fileserv.rs
+++ b/src/fileserv.rs
@@ -2,7 +2,7 @@ use cfg_if::cfg_if;
cfg_if! { if #[cfg(feature = "ssr")] {
use axum::{
- body::{boxed, Body, BoxBody},
+ body::Body,
extract::State,
response::IntoResponse,
http::{Request, Response, StatusCode, Uri},
@@ -20,17 +20,17 @@ cfg_if! { if #[cfg(feature = "ssr")] {
if res.status() == StatusCode::OK {
res.into_response()
} else {
- let handler = leptos_axum::render_app_to_stream(options.to_owned(), move || view!{});
+ let handler = leptos_axum::render_app_to_stream(options.to_owned(), App);
handler(req).await.into_response()
}
}
- async fn get_static_file(uri: Uri, root: &str) -> Result, (StatusCode, String)> {
+ async fn get_static_file(uri: Uri, root: &str) -> Result, (StatusCode, String)> {
let req = Request::builder().uri(uri.clone()).body(Body::empty()).unwrap();
// `ServeDir` implements `tower::Service` so we can call it with `tower::ServiceExt::oneshot`
// This path is relative to the cargo root
match ServeDir::new(root).oneshot(req).await {
- Ok(res) => Ok(res.map(boxed)),
+ Ok(res) => Ok(res.into_response()),
Err(err) => Err((
StatusCode::INTERNAL_SERVER_ERROR,
format!("Something went wrong: {err}"),
diff --git a/src/main.rs b/src/main.rs
index 3c7054f..f7b99da 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -42,10 +42,8 @@ async fn main() {
println!("listening on http://{}", &addr);
- axum::Server::bind(&addr)
- .serve(app.into_make_service())
- .await
- .unwrap();
+ let listener = tokio::net::TcpListener::bind(&addr).await.expect(&format!("Could not bind to {}", &addr));
+ axum::serve(listener, app.into_make_service()).await.expect("Server failed");
}
#[cfg(not(any(feature = "ssr", feature = "csr")))]