Axum hello world
This commit is contained in:
parent
daa8ea00ba
commit
1e02b39199
4 changed files with 772 additions and 3 deletions
|
|
@ -1,3 +1,20 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
use axum::{Router, routing::get};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
let app = Router::new().route("/health", get(health));
|
||||
|
||||
let addr = "127.0.0.1:3000";
|
||||
|
||||
let listener = tokio::net::TcpListener::bind(addr).await.unwrap();
|
||||
|
||||
tracing::info!("API Server listening on {}", listener.local_addr().unwrap());
|
||||
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
}
|
||||
|
||||
async fn health() -> &'static str {
|
||||
"Ok"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue