aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCara Salter <cara@devcara.com>2022-06-09 12:58:56 -0400
committerCara Salter <cara@devcara.com>2022-06-09 12:58:56 -0400
commitb81eaf785286519b9e5b7725cc4d4dd66175a892 (patch)
treeffe996d3672bd41009b5a4e7b0af4294a227d321 /src
parent276255f5a20fa05a005e765287239ca5ffe439e4 (diff)
downloadsolard-b81eaf785286519b9e5b7725cc4d4dd66175a892.tar.gz
solard-b81eaf785286519b9e5b7725cc4d4dd66175a892.zip
main: Add 404 handler
Diffstat (limited to 'src')
-rw-r--r--src/main.rs8
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
+}