Skip to content
This repository was archived by the owner on Jun 9, 2022. It is now read-only.

Commit 8298080

Browse files
committed
Update helpers/problem.rs
- Update unpack() function to handle METHOD_NOT_ALLOWED.
1 parent eea8dff commit 8298080

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/helpers/problem.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ pub fn build<E: Into<anyhow::Error>>(err: E) -> Rejection {
99
}
1010

1111
pub fn pack(err: anyhow::Error) -> Problem {
12-
tracing::info!("pack: {:#?}", err);
1312
let err = match err.downcast::<Problem>() {
1413
Ok(problem) => return problem,
15-
1614
Err(err) => err,
1715
};
1816

@@ -23,7 +21,6 @@ pub fn pack(err: anyhow::Error) -> Problem {
2321
.set_status(http::StatusCode::BAD_REQUEST)
2422
.set_detail("The passed credentials were invalid.")
2523
}
26-
2724
auth::AuthError::ArgonError => (),
2825
}
2926
}
@@ -63,6 +60,10 @@ pub async fn unpack(rejection: Rejection) -> Result<impl Reply, Infallible> {
6360
let reply = if rejection.is_not_found() {
6461
let problem = Problem::with_title_and_type_from_status(http::StatusCode::NOT_FOUND);
6562
reply_from_problem(&problem)
63+
} else if let Some(_) = rejection.find::<warp::reject::MethodNotAllowed>() {
64+
let problem =
65+
Problem::with_title_and_type_from_status(http::StatusCode::METHOD_NOT_ALLOWED);
66+
reply_from_problem(&problem)
6667
} else if let Some(problem) = rejection.find::<Problem>() {
6768
reply_from_problem(problem)
6869
} else if let Some(e) = rejection.find::<warp::filters::body::BodyDeserializeError>() {

0 commit comments

Comments
 (0)