Skip to content

Commit

Permalink
axum-core/macros: Avoid double body_text() calls in rejection macros
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Dec 26, 2024
1 parent a5de589 commit 254ca6d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions axum-core/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ macro_rules! __define_rejection {

impl $crate::response::IntoResponse for $name {
fn into_response(self) -> $crate::response::Response {
let status = self.status();
let body_text = self.body_text();

$crate::__log_rejection!(
rejection_type = $name,
body_text = $body,
status = http::StatusCode::$status,
body_text = body_text,
status = status,
);
(self.status(), $body).into_response()
(status, body_text).into_response()
}
}

Expand Down Expand Up @@ -106,12 +109,15 @@ macro_rules! __define_rejection {

impl $crate::response::IntoResponse for $name {
fn into_response(self) -> $crate::response::Response {
let status = self.status();
let body_text = self.body_text();

$crate::__log_rejection!(
rejection_type = $name,
body_text = self.body_text(),
status = http::StatusCode::$status,
body_text = body_text,
status = status,
);
(self.status(), self.body_text()).into_response()
(status, body_text).into_response()
}
}

Expand Down

0 comments on commit 254ca6d

Please sign in to comment.