mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-14 00:00:15 +02:00
axum-core/macros: Move IntoResponse impls below regular impl blocks (#3116)
This commit is contained in:
+22
-24
@@ -47,6 +47,18 @@ macro_rules! __define_rejection {
|
||||
#[non_exhaustive]
|
||||
pub struct $name;
|
||||
|
||||
impl $name {
|
||||
/// Get the response body text used for this rejection.
|
||||
pub fn body_text(&self) -> String {
|
||||
$body.into()
|
||||
}
|
||||
|
||||
/// Get the status code used for this rejection.
|
||||
pub fn status(&self) -> http::StatusCode {
|
||||
http::StatusCode::$status
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::response::IntoResponse for $name {
|
||||
fn into_response(self) -> $crate::response::Response {
|
||||
let status = self.status();
|
||||
@@ -60,18 +72,6 @@ macro_rules! __define_rejection {
|
||||
}
|
||||
}
|
||||
|
||||
impl $name {
|
||||
/// Get the response body text used for this rejection.
|
||||
pub fn body_text(&self) -> String {
|
||||
$body.into()
|
||||
}
|
||||
|
||||
/// Get the status code used for this rejection.
|
||||
pub fn status(&self) -> http::StatusCode {
|
||||
http::StatusCode::$status
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for $name {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", $body)
|
||||
@@ -104,6 +104,16 @@ macro_rules! __define_rejection {
|
||||
{
|
||||
Self($crate::Error::new(err))
|
||||
}
|
||||
|
||||
/// Get the response body text used for this rejection.
|
||||
pub fn body_text(&self) -> String {
|
||||
format!(concat!($body, ": {}"), self.0).into()
|
||||
}
|
||||
|
||||
/// Get the status code used for this rejection.
|
||||
pub fn status(&self) -> http::StatusCode {
|
||||
http::StatusCode::$status
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::response::IntoResponse for $name {
|
||||
@@ -120,18 +130,6 @@ macro_rules! __define_rejection {
|
||||
}
|
||||
}
|
||||
|
||||
impl $name {
|
||||
/// Get the response body text used for this rejection.
|
||||
pub fn body_text(&self) -> String {
|
||||
format!(concat!($body, ": {}"), self.0).into()
|
||||
}
|
||||
|
||||
/// Get the status code used for this rejection.
|
||||
pub fn status(&self) -> http::StatusCode {
|
||||
http::StatusCode::$status
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for $name {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", $body)
|
||||
|
||||
Reference in New Issue
Block a user