diff --git a/src/cal/day00.rs b/src/cal/day00.rs new file mode 100644 index 0000000..2d55dde --- /dev/null +++ b/src/cal/day00.rs @@ -0,0 +1,15 @@ +use axum::{http::StatusCode, response::IntoResponse, routing::get, Router}; + +pub(crate) fn router() -> Router { + Router::new() + .route("/", get(hello_world)) + .route("/-1/error", get(fake_error)) +} + +async fn hello_world() -> impl IntoResponse { + "Hello, world!" +} + +async fn fake_error() -> impl IntoResponse { + StatusCode::INTERNAL_SERVER_ERROR +} diff --git a/src/cal/mod.rs b/src/cal/mod.rs new file mode 100644 index 0000000..a9dda0c --- /dev/null +++ b/src/cal/mod.rs @@ -0,0 +1,6 @@ +mod day00; + +pub(crate) fn router() -> axum::Router { + axum::Router::new() + .nest("/", day00::router()) +} diff --git a/src/main.rs b/src/main.rs index c36b6b8..e54ff99 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,18 +1,6 @@ -use axum::{http::StatusCode, response::IntoResponse, routing::get, Router}; - -async fn hello_world() -> impl IntoResponse { - "Hello, world!" -} - -async fn fake_error() -> impl IntoResponse { - StatusCode::INTERNAL_SERVER_ERROR -} +mod cal; #[shuttle_runtime::main] async fn main() -> shuttle_axum::ShuttleAxum { - let router = Router::new() - .route("/", get(hello_world)) - .route("/-1/error", get(fake_error)); - - Ok(router.into()) + Ok(axum::Router::new().nest("/", cal::router()).into()) }