Skip to content
Myr

main.rs

This file

Path

examples/customize-extractor-error/src/main.rs

36 lines · 1.1 KiB · Rust

Last changed by

Fix return types of serve futures (#3601)Jonas Plattebefore adoptionf3a95d7

History of this file

Take it

1//! Run with2//!3//! ```not_rust4//! cargo run -p example-customize-extractor-error5//! ```67mod custom_extractor;8mod derive_from_request;9mod with_rejection;1011use axum::{routing::post, Router};12use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};1314#[tokio::main]15async fn main() {16    tracing_subscriber::registry()17        .with(18            tracing_subscriber::EnvFilter::try_from_default_env()19                .unwrap_or_else(|_| format!("{}=trace", env!("CARGO_CRATE_NAME")).into()),20        )21        .with(tracing_subscriber::fmt::layer())22        .init();2324    // Build our application with some routes25    let app = Router::new()26        .route("/with-rejection", post(with_rejection::handler))27        .route("/custom-extractor", post(custom_extractor::handler))28        .route("/derive-from-request", post(derive_from_request::handler));2930    // Run our application31    let listener = tokio::net::TcpListener::bind("127.0.0.1:3000")32        .await33        .unwrap();34    tracing::debug!("listening on {}", listener.local_addr().unwrap());35    axum::serve(listener, app).await;36}