axum/axum-macros/tests/from_request/pass/state_field_infer.rs

18 lines
371 B
Rust
Raw Permalink Normal View History

2024-11-26 19:04:01 +01:00
use axum::{extract::State, routing::get, Router};
use axum_macros::FromRequest;
fn main() {
let _: axum::Router = Router::new()
.route("/", get(|_: Extractor| async {}))
.with_state(AppState::default());
}
#[derive(FromRequest)]
struct Extractor {
#[from_request(via(State))]
state: AppState,
}
#[derive(Clone, Default)]
struct AppState {}