mysten_service/
service.rs1use crate::DEFAULT_PORT;
5use crate::health::HealthResponse;
6use anyhow::Result;
7use axum::Json;
8use axum::Router;
9use axum::routing::get;
10use tracing::debug;
11
12pub fn get_mysten_service<S>(app_name: &str, app_version: &str) -> Router<S>
13where
14 S: Send + Clone + Sync + 'static,
15{
16 Router::new().route(
18 "/health",
19 get(Json(HealthResponse::new(app_name, app_version))),
20 )
21}
22
23pub async fn serve(app: Router) -> Result<()> {
24 debug!("listening on http://localhost:{}", DEFAULT_PORT);
26
27 let listener = tokio::net::TcpListener::bind(&format!("0.0.0.0:{}", DEFAULT_PORT))
28 .await
29 .unwrap();
30 axum::serve(listener, app).await?;
31 Ok(())
32}