mirror of
https://github.com/tokio-rs/axum.git
synced 2025-01-04 02:01:23 +01:00
axum-core/macros: Move IntoResponse
impls below regular impl
blocks (#3116)
This commit is contained in:
parent
7c934f2a83
commit
fd60c8471d
1 changed files with 22 additions and 24 deletions
|
@ -47,6 +47,18 @@ macro_rules! __define_rejection {
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub struct $name;
|
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 {
|
impl $crate::response::IntoResponse for $name {
|
||||||
fn into_response(self) -> $crate::response::Response {
|
fn into_response(self) -> $crate::response::Response {
|
||||||
let status = self.status();
|
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 {
|
impl std::fmt::Display for $name {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "{}", $body)
|
write!(f, "{}", $body)
|
||||||
|
@ -104,6 +104,16 @@ macro_rules! __define_rejection {
|
||||||
{
|
{
|
||||||
Self($crate::Error::new(err))
|
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 {
|
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 {
|
impl std::fmt::Display for $name {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "{}", $body)
|
write!(f, "{}", $body)
|
||||||
|
|
Loading…
Reference in a new issue