1#![forbid(unsafe_code)]
9#![warn(missing_docs)]
10
11use axum::{routing::get, Json, Router};
12use serde_json::{json, Value};
13use sz_rust_core::error::ErrorCode;
14use sz_rust_core::sql_string;
15use tower_http::trace::TraceLayer;
16
17pub async fn hello() -> Json<Value> {
24 let _sql = sql_string!("SELECT 1 FROM dual");
26
27 Json(json!({
29 "code": ErrorCode::Success as i32,
30 "msg": "hello",
31 "data": {},
32 }))
33}
34
35pub async fn health() -> Json<Value> {
37 Json(json!({
38 "code": ErrorCode::Success as i32,
39 "msg": "ok",
40 "data": {
41 "status": "healthy",
42 "version": env!("CARGO_PKG_VERSION"),
43 },
44 }))
45}
46
47pub fn build_router() -> Router {
49 Router::new()
50 .route("/", get(hello))
51 .route("/health", get(health))
52 .layer(TraceLayer::new_for_http())
53}