diff --git a/src/callers/common.rs b/src/callers/common.rs index c39654b..bdf5e0b 100644 --- a/src/callers/common.rs +++ b/src/callers/common.rs @@ -1,4 +1,21 @@ +use axum::{Json, http::StatusCode}; + +use serde::{Deserialize, Serialize}; + +#[derive(Deserialize, Serialize)] +pub struct TestResult { + message: String, +} + // basic handler that responds with a static string pub async fn root() -> &'static str { "Hello, World!" } + +pub async fn db_ping() -> (StatusCode, Json) { + let tr = TestResult { + message: String::from("Should work"), + }; + + (StatusCode::OK, Json(tr)) +} diff --git a/src/callers/mod.rs b/src/callers/mod.rs index ada84ab..33ddec1 100644 --- a/src/callers/mod.rs +++ b/src/callers/mod.rs @@ -4,4 +4,5 @@ pub mod register; pub mod endpoints { pub const ROOT: &str = "/"; pub const REGISTER: &str = "/api/v2/register"; + pub const DBTEST: &str = "/api/v2/test/db"; } diff --git a/src/main.rs b/src/main.rs index 4560611..db3d182 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,6 +19,7 @@ async fn main() { // build our application with a route let app = Router::new() .layer(axum::Extension(pool)) + .route(callers::endpoints::DBTEST, get(callers::common::db_ping)) .route(callers::endpoints::ROOT, get(callers::common::root)) .route( callers::endpoints::REGISTER,