2022-09-23 23:50:50 +02:00
|
|
|
use std::convert::Infallible;
|
|
|
|
use axum::{
|
|
|
|
extract::State,
|
|
|
|
response::{IntoResponse, Response},
|
|
|
|
routing::get,
|
|
|
|
Router,
|
|
|
|
};
|
|
|
|
use axum_macros::FromRequest;
|
|
|
|
|
|
|
|
fn main() {
|
2022-11-24 15:43:10 +01:00
|
|
|
let _: axum::Router = Router::new()
|
2022-11-18 12:02:58 +01:00
|
|
|
.route("/a", get(|_: Extractor| async {}))
|
|
|
|
.with_state(AppState::default());
|
2022-09-23 23:50:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Default, FromRequest)]
|
|
|
|
#[from_request(rejection(MyRejection))]
|
|
|
|
struct Extractor {
|
|
|
|
state: State<AppState>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Default)]
|
|
|
|
struct AppState {}
|
|
|
|
|
|
|
|
struct MyRejection {}
|
|
|
|
|
|
|
|
impl From<Infallible> for MyRejection {
|
|
|
|
fn from(err: Infallible) -> Self {
|
|
|
|
match err {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl IntoResponse for MyRejection {
|
|
|
|
fn into_response(self) -> Response {
|
|
|
|
().into_response()
|
|
|
|
}
|
|
|
|
}
|