@@ -26,13 +26,10 @@ pub fn pack(err: anyhow::Error) -> Problem {
2626 }
2727
2828 if let Some ( err) = err. downcast_ref :: < biscuit:: errors:: Error > ( ) {
29- match err {
30- biscuit:: errors:: Error :: ValidationError ( e) => {
31- return Problem :: new ( "Invalid JWT token." )
32- . set_status ( http:: StatusCode :: BAD_REQUEST )
33- . set_detail ( format ! ( "The passed JWT token were invalid. {}" , e) )
34- }
35- _ => ( ) ,
29+ if let biscuit:: errors:: Error :: ValidationError ( e) = err {
30+ return Problem :: new ( "Invalid JWT token." )
31+ . set_status ( http:: StatusCode :: BAD_REQUEST )
32+ . set_detail ( format ! ( "The passed JWT token were invalid. {}" , e) ) ;
3633 }
3734 }
3835
@@ -47,13 +44,11 @@ fn reply_from_problem(problem: &Problem) -> impl Reply {
4744
4845 let reply = warp:: reply:: json ( problem) ;
4946 let reply = warp:: reply:: with_status ( reply, code) ;
50- let reply = warp:: reply:: with_header (
47+ warp:: reply:: with_header (
5148 reply,
5249 http:: header:: CONTENT_TYPE ,
5350 http_api_problem:: PROBLEM_JSON_MEDIA_TYPE ,
54- ) ;
55-
56- reply
51+ )
5752}
5853
5954pub async fn unpack ( rejection : Rejection ) -> Result < impl Reply , Infallible > {
@@ -67,7 +62,7 @@ pub async fn unpack(rejection: Rejection) -> Result<impl Reply, Infallible> {
6762 . set_status ( http:: StatusCode :: BAD_REQUEST )
6863 . set_detail ( format ! ( "Request body is invalid. {}" , e) ) ;
6964 reply_from_problem ( & problem)
70- } else if let Some ( _ ) = rejection. find :: < warp:: reject:: MethodNotAllowed > ( ) {
65+ } else if rejection. find :: < warp:: reject:: MethodNotAllowed > ( ) . is_some ( ) {
7166 let problem =
7267 Problem :: with_title_and_type_from_status ( http:: StatusCode :: METHOD_NOT_ALLOWED ) ;
7368 reply_from_problem ( & problem)
0 commit comments