#![forbid(unsafe_code)]
#![warn(missing_docs)]
use axum::{routing::get, Json, Router};
use serde_json::{json, Value};
use sz_rust_core::error::ErrorCode;
use sz_rust_core::sql_string;
use tower_http::trace::TraceLayer;
pub async fn hello() -> Json<Value> {
let _sql = sql_string!("SELECT 1 FROM dual");
Json(json!({
"code": ErrorCode::Success as i32,
"msg": "hello",
"data": {},
}))
}
pub async fn health() -> Json<Value> {
Json(json!({
"code": ErrorCode::Success as i32,
"msg": "ok",
"data": {
"status": "healthy",
"version": env!("CARGO_PKG_VERSION"),
},
}))
}
pub fn build_router() -> Router {
Router::new()
.route("/", get(hello))
.route("/health", get(health))
.layer(TraceLayer::new_for_http())
}