mirror of
https://github.com/supleed2/cch23-8bit.git
synced 2024-12-22 22:15:49 +00:00
Reorganise code by day
This commit is contained in:
parent
a786c6ac4a
commit
769f5cb129
15
src/cal/day00.rs
Normal file
15
src/cal/day00.rs
Normal 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
6
src/cal/mod.rs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
mod day00;
|
||||||
|
|
||||||
|
pub(crate) fn router() -> axum::Router {
|
||||||
|
axum::Router::new()
|
||||||
|
.nest("/", day00::router())
|
||||||
|
}
|
16
src/main.rs
16
src/main.rs
|
@ -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())
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue