Added more code
This commit is contained in:
@@ -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
|
// basic handler that responds with a static string
|
||||||
pub async fn root() -> &'static str {
|
pub async fn root() -> &'static str {
|
||||||
"Hello, World!"
|
"Hello, World!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn db_ping() -> (StatusCode, Json<TestResult>) {
|
||||||
|
let tr = TestResult {
|
||||||
|
message: String::from("Should work"),
|
||||||
|
};
|
||||||
|
|
||||||
|
(StatusCode::OK, Json(tr))
|
||||||
|
}
|
||||||
|
@@ -4,4 +4,5 @@ pub mod register;
|
|||||||
pub mod endpoints {
|
pub mod endpoints {
|
||||||
pub const ROOT: &str = "/";
|
pub const ROOT: &str = "/";
|
||||||
pub const REGISTER: &str = "/api/v2/register";
|
pub const REGISTER: &str = "/api/v2/register";
|
||||||
|
pub const DBTEST: &str = "/api/v2/test/db";
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,7 @@ async fn main() {
|
|||||||
// build our application with a route
|
// build our application with a route
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.layer(axum::Extension(pool))
|
.layer(axum::Extension(pool))
|
||||||
|
.route(callers::endpoints::DBTEST, get(callers::common::db_ping))
|
||||||
.route(callers::endpoints::ROOT, get(callers::common::root))
|
.route(callers::endpoints::ROOT, get(callers::common::root))
|
||||||
.route(
|
.route(
|
||||||
callers::endpoints::REGISTER,
|
callers::endpoints::REGISTER,
|
||||||
|
Reference in New Issue
Block a user