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 authored Dec 27, 2024
1 parent 32a948e commit 7c934f2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions axum-core/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ macro_rules! __define_rejection {

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

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

Expand Down Expand Up @@ -106,12 +108,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 7c934f2

Please sign in to comment.