mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-25 00:00:23 +02:00
Remove some needless type params
This commit is contained in:
@@ -10,7 +10,7 @@ macro_rules! define_rejection {
|
||||
#[derive(Debug)]
|
||||
pub struct $name(pub(super) ());
|
||||
|
||||
impl IntoResponse<Body> for $name {
|
||||
impl IntoResponse for $name {
|
||||
fn into_response(self) -> http::Response<Body> {
|
||||
let mut res = http::Response::new(Body::from($body));
|
||||
*res.status_mut() = http::StatusCode::$status;
|
||||
@@ -36,7 +36,7 @@ macro_rules! define_rejection {
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoResponse<Body> for $name {
|
||||
impl IntoResponse for $name {
|
||||
fn into_response(self) -> http::Response<Body> {
|
||||
let mut res =
|
||||
http::Response::new(Body::from(format!(concat!($body, ": {}"), self.0)));
|
||||
@@ -106,3 +106,27 @@ define_rejection! {
|
||||
#[body = "Cannot have two request body extractors for a single handler"]
|
||||
pub struct BodyAlreadyTaken(());
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct InvalidUrlParam {
|
||||
type_name: &'static str,
|
||||
}
|
||||
|
||||
impl InvalidUrlParam {
|
||||
pub(super) fn new<T>() -> Self {
|
||||
InvalidUrlParam {
|
||||
type_name: std::any::type_name::<T>(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoResponse for InvalidUrlParam {
|
||||
fn into_response(self) -> http::Response<Body> {
|
||||
let mut res = http::Response::new(Body::from(format!(
|
||||
"Invalid URL param. Expected something of type `{}`",
|
||||
self.type_name
|
||||
)));
|
||||
*res.status_mut() = http::StatusCode::BAD_REQUEST;
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user