mirror of
https://github.com/tokio-rs/axum.git
synced 2024-11-23 07:39:25 +01:00
18 lines
421 B
Rust
18 lines
421 B
Rust
|
use axum::{
|
||
|
extract::State,
|
||
|
routing::get,
|
||
|
Router,
|
||
|
};
|
||
|
use axum_macros::FromRequest;
|
||
|
|
||
|
fn main() {
|
||
|
let _: Router<AppState> = Router::with_state(AppState::default())
|
||
|
.route("/b", get(|_: AppState| async {}));
|
||
|
}
|
||
|
|
||
|
// 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 {}
|