Reorganise code by day

This commit is contained in:
Aadi Desai 2023-12-01 15:44:48 +00:00
parent a786c6ac4a
commit 769f5cb129
Signed by: supleed2
SSH key fingerprint: SHA256:CkbNRs0yVzXEiUp2zd0PSxsfRUMFF9bLlKXtE1xEbKM
3 changed files with 23 additions and 14 deletions

15
src/cal/day00.rs Normal file
View file

@ -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
}

6
src/cal/mod.rs Normal file
View file

@ -0,0 +1,6 @@
mod day00;
pub(crate) fn router() -> axum::Router {
axum::Router::new()
.nest("/", day00::router())
}

View file

@ -1,18 +1,6 @@
use axum::{http::StatusCode, response::IntoResponse, routing::get, Router}; mod cal;
async fn hello_world() -> impl IntoResponse {
"Hello, world!"
}
async fn fake_error() -> impl IntoResponse {
StatusCode::INTERNAL_SERVER_ERROR
}
#[shuttle_runtime::main] #[shuttle_runtime::main]
async fn main() -> shuttle_axum::ShuttleAxum { async fn main() -> shuttle_axum::ShuttleAxum {
let router = Router::new() Ok(axum::Router::new().nest("/", cal::router()).into())
.route("/", get(hello_world))
.route("/-1/error", get(fake_error));
Ok(router.into())
} }