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