diff --git a/src/main.rs b/src/main.rs index 9d0faf5..a6ccf84 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ mod routes; mod setup; use axum::Router; +use routes::routes; use tokio::net::TcpListener; use tracing::{error, info}; @@ -10,9 +11,7 @@ async fn main() { setup::initialise_dotenv(); setup::initialise_sqlite_db_tables(); - let app = Router::new() - .merge(routes::health::route()) - .merge(routes::splash::randsplash_route()); + let app = Router::new().merge(routes()); let addr = setup::get_socket_addr(); let listener = match TcpListener::bind(&addr).await { diff --git a/src/routes/health.rs b/src/routes/health.rs index fb10c93..ac6aafa 100644 --- a/src/routes/health.rs +++ b/src/routes/health.rs @@ -1,9 +1,11 @@ use axum::{http::StatusCode, routing::get, Router}; pub fn route() -> Router { - Router::new().route("/health", get(health())) + Router::new() + .route("/live", get(empty())) + .route("/health", get(empty())) } -fn health() -> StatusCode { +fn empty() -> StatusCode { StatusCode::OK } diff --git a/src/routes/mod.rs b/src/routes/mod.rs index dd56a14..24af8be 100644 --- a/src/routes/mod.rs +++ b/src/routes/mod.rs @@ -1,2 +1,12 @@ +use axum::Router; + pub mod health; pub mod splash; +pub mod teapot; + +pub fn routes() -> Router { + Router::new() + .merge(health::route()) + .merge(splash::route()) + .merge(teapot::route()) +} diff --git a/src/routes/splash.rs b/src/routes/splash.rs index 45cda2e..d454174 100644 --- a/src/routes/splash.rs +++ b/src/routes/splash.rs @@ -1,6 +1,6 @@ use axum::{routing::get, Router}; -pub fn randsplash_route() -> Router { +pub fn route() -> Router { Router::new().route("/splash", get(random_splash())) } diff --git a/src/routes/teapot.rs b/src/routes/teapot.rs new file mode 100644 index 0000000..ac20dd5 --- /dev/null +++ b/src/routes/teapot.rs @@ -0,0 +1,11 @@ +use axum::{http::StatusCode, routing::get, Router}; + +pub fn route() -> Router { + Router::new() + .route("/brew-coffee", get(refuse_to_brew_coffee())) + .route("/brew", get(refuse_to_brew_coffee())) +} + +fn refuse_to_brew_coffee() -> StatusCode { + StatusCode::IM_A_TEAPOT +}