mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-29 00:00:18 +02:00
Implement TypedPath for WithRejection<TypedPath, _> (#2491)
This commit is contained in:
@@ -386,7 +386,15 @@ impl_second_element_is!(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::routing::TypedPath;
|
||||
use crate::{
|
||||
extract::WithRejection,
|
||||
routing::{RouterExt, TypedPath},
|
||||
};
|
||||
use axum::{
|
||||
extract::rejection::PathRejection,
|
||||
response::{IntoResponse, Response},
|
||||
Router,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(TypedPath, Deserialize)]
|
||||
@@ -434,4 +442,25 @@ mod tests {
|
||||
|
||||
assert_eq!(uri, "/users/1?&foo=foo&bar=123&baz=true&qux=1337");
|
||||
}
|
||||
|
||||
#[allow(dead_code)] // just needs to compile
|
||||
fn supports_with_rejection() {
|
||||
async fn handler(_: WithRejection<UsersShow, MyRejection>) {}
|
||||
|
||||
struct MyRejection {}
|
||||
|
||||
impl IntoResponse for MyRejection {
|
||||
fn into_response(self) -> Response {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PathRejection> for MyRejection {
|
||||
fn from(_: PathRejection) -> Self {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
let _: Router = Router::new().typed_get(handler);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user