mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-07 00:00:12 +02:00
Implement TypedPath for WithRejection<TypedPath, _> (#2491)
This commit is contained in:
@@ -2,10 +2,13 @@ use axum::async_trait;
|
||||
use axum::extract::{FromRequest, FromRequestParts, Request};
|
||||
use axum::response::IntoResponse;
|
||||
use http::request::Parts;
|
||||
use std::fmt::Debug;
|
||||
use std::fmt::{Debug, Display};
|
||||
use std::marker::PhantomData;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
#[cfg(feature = "typed-routing")]
|
||||
use crate::routing::TypedPath;
|
||||
|
||||
/// Extractor for customizing extractor rejections
|
||||
///
|
||||
/// `WithRejection` wraps another extractor and gives you the result. If the
|
||||
@@ -137,6 +140,23 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "typed-routing")]
|
||||
impl<E, R> TypedPath for WithRejection<E, R>
|
||||
where
|
||||
E: TypedPath,
|
||||
{
|
||||
const PATH: &'static str = E::PATH;
|
||||
}
|
||||
|
||||
impl<E, R> Display for WithRejection<E, R>
|
||||
where
|
||||
E: Display,
|
||||
{
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use axum::body::Body;
|
||||
|
||||
Reference in New Issue
Block a user