diff options
author | Tyler Murphy <tylermurphy534@gmail.com> | 2023-01-28 13:14:53 -0500 |
---|---|---|
committer | Tyler Murphy <tylermurphy534@gmail.com> | 2023-01-28 13:14:53 -0500 |
commit | f3f5e03651e27c2bb5492ac50b6ae91a9336411c (patch) | |
tree | f23f1e3bc2c1007ccdd9fd64b3df0f316c868e26 /src/main.rs | |
parent | tracing (diff) | |
download | xssbook-f3f5e03651e27c2bb5492ac50b6ae91a9336411c.tar.gz xssbook-f3f5e03651e27c2bb5492ac50b6ae91a9336411c.tar.bz2 xssbook-f3f5e03651e27c2bb5492ac50b6ae91a9336411c.zip |
docker
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] |