diff options
author | Cara Salter <cara@devcara.com> | 2022-06-09 12:58:56 -0400 |
---|---|---|
committer | Cara Salter <cara@devcara.com> | 2022-06-09 12:58:56 -0400 |
commit | b81eaf785286519b9e5b7725cc4d4dd66175a892 (patch) | |
tree | ffe996d3672bd41009b5a4e7b0af4294a227d321 /src/main.rs | |
parent | 276255f5a20fa05a005e765287239ca5ffe439e4 (diff) | |
download | solard-b81eaf785286519b9e5b7725cc4d4dd66175a892.tar.gz solard-b81eaf785286519b9e5b7725cc4d4dd66175a892.zip |
main: Add 404 handler
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 742113e..28036d4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ use axum::{ http::StatusCode, response::IntoResponse, routing::{get, post}, + handler::Handler, Json, Router }; @@ -52,7 +53,8 @@ async fn main() { .timeout(Duration::from_secs(10)) .layer(TraceLayer::new_for_http()) .into_inner(), - ); + ) + .fallback(handler_404.into_service()); let addr = SocketAddr::from_str(std::env::var("BIND_ADDR").unwrap().as_str().into()).unwrap(); tracing::info!("Listening on {}", addr); @@ -72,3 +74,7 @@ fn get_star() -> Result<Star, errors::ServiceError> { Ok(Star::new(con_url)?) } + +async fn handler_404() -> impl IntoResponse { + StatusCode::NOT_FOUND +} |