mirror of
https://github.com/tokio-rs/axum.git
synced 2024-12-29 15:49:16 +01:00
14 lines
417 B
Rust
14 lines
417 B
Rust
use axum::{extract::State, routing::get, Router};
|
|
use axum_macros::FromRequest;
|
|
|
|
fn main() {
|
|
let _: axum::Router = Router::new()
|
|
.route("/b", get(|_: AppState| async {}))
|
|
.with_state(AppState::default());
|
|
}
|
|
|
|
// if we're extract "via" `State<AppState>` and not specifying state
|
|
// assume `AppState` is the state
|
|
#[derive(Clone, Default, FromRequest)]
|
|
#[from_request(via(State))]
|
|
struct AppState {}
|