File tree Expand file tree Collapse file tree 1 file changed +8
-14
lines changed Expand file tree Collapse file tree 1 file changed +8
-14
lines changed Original file line number Diff line number Diff line change @@ -104,12 +104,12 @@ where
104104 type Rejection = JsonRejection ;
105105
106106 async fn from_request ( req : Request , state : & S ) -> Result < Self , Self :: Rejection > {
107- if json_content_type ( req. headers ( ) ) {
108- let bytes = Bytes :: from_request ( req, state) . await ?;
109- Self :: from_bytes ( & bytes)
110- } else {
111- Err ( MissingJsonContentType . into ( ) )
107+ if !json_content_type ( req. headers ( ) ) {
108+ return Err ( MissingJsonContentType . into ( ) ) ;
112109 }
110+
111+ let bytes = Bytes :: from_request ( req, state) . await ?;
112+ Self :: from_bytes ( & bytes)
113113 }
114114}
115115
@@ -136,21 +136,15 @@ where
136136}
137137
138138fn json_content_type ( headers : & HeaderMap ) -> bool {
139- let content_type = if let Some ( content_type) = headers. get ( header:: CONTENT_TYPE ) {
140- content_type
141- } else {
139+ let Some ( content_type) = headers. get ( header:: CONTENT_TYPE ) else {
142140 return false ;
143141 } ;
144142
145- let content_type = if let Ok ( content_type) = content_type. to_str ( ) {
146- content_type
147- } else {
143+ let Ok ( content_type) = content_type. to_str ( ) else {
148144 return false ;
149145 } ;
150146
151- let mime = if let Ok ( mime) = content_type. parse :: < mime:: Mime > ( ) {
152- mime
153- } else {
147+ let Ok ( mime) = content_type. parse :: < mime:: Mime > ( ) else {
154148 return false ;
155149 } ;
156150
You can’t perform that action at this time.
0 commit comments