How to Build a REST API with Axum in Rust

Build a REST API in Rust using Axum and Tokio by defining routes and running an async server.

Use Axum with Tokio to define routes, handle requests, and run the server asynchronously.

use axum::{routing::get, Router};

#[tokio::main]
async fn main() {
    let app = Router::new().route("/", get(|| async { "Hello, Axum!" }));
    let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
    axum::serve(listener, app).await.unwrap();
}