diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs index ab5a9cc..ebce57e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ use std::net::SocketAddr; -use axum::{Router, response::Response, http::Request, middleware::{Next, self}, extract::ConnectInfo, RequestExt, body::HttpBody, Extension}; +use axum::{Router, response::Response, http::{Request, StatusCode}, middleware::{Next, self}, extract::ConnectInfo, RequestExt, body::HttpBody, Extension}; use tower_cookies::CookieManagerLayer; use tracing::metadata::LevelFilter; use tracing_subscriber::{prelude::__tracing_subscriber_SubscriberExt, util::SubscriberInitExt, Layer, filter::filter_fn}; @@ -13,9 +13,10 @@ mod types; mod console; async fn serve<B>(req: Request<B>, next: Next<B>) -> Response { - let Ok(file) = ResponseCode::Success.file(&req.uri().to_string()).await else { - return next.run(req).await - }; + let file = ResponseCode::Success.file(&req.uri().to_string()).await; + if file.status() != StatusCode::OK { + return next.run(req).await; + } file } @@ -33,10 +34,7 @@ async fn log<B>(mut req: Request<B>, next: Next<B>) -> Response where } async fn not_found() -> Response { - match ResponseCode::NotFound.file("/404.html").await { - Ok(file) => file, - Err(err) => err - } + ResponseCode::NotFound.file("/404.html").await } #[tokio::main] |