use axum::middleware::from_fn; use axum::routing::get; use axum::{Extension, Router}; use libslonk::filtered_path::{FilteredPath, SlashFilter}; use libslonk::{request_id, trace_layer_with_ulid}; use tokio::net::TcpListener; use ulid::Ulid; async fn say_hello( Extension(id): Extension, FilteredPath(name, ..): FilteredPath, ) -> String { format!("Hello, {name}. Your request has the ULID: {id}\n") } #[tokio::main] async fn main() { let router = Router::new() .route("/{name}", get(say_hello)) .layer(trace_layer_with_ulid!()) .layer(from_fn(request_id)); axum::serve(TcpListener::bind("[::]:3000").await.unwrap(), router) .await .unwrap(); }