示例代码(main.rs):use axum::{routing::get, Router, response::IntoResponse}; use tower_http::trace::TraceLayer; async fn ping() -> impl IntoResponse { (axum::http::StatusCode::OK, "{\"pong\":true}") } #[tokio::main] async fn main() { tracing_subscriber::fmt::init(); let app = Router::new() .route("/api/ping", get(ping)) .layer(TraceLayer::new_for_http()); let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap(); axum::serve(listener, app).await.unwrap(); }

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部