File tree Expand file tree Collapse file tree 1 file changed +8
-16
lines changed Expand file tree Collapse file tree 1 file changed +8
-16
lines changed Original file line number Diff line number Diff line change @@ -136,22 +136,14 @@ where
136
136
}
137
137
138
138
fn json_content_type ( headers : & HeaderMap ) -> bool {
139
- let Some ( content_type) = headers. get ( header:: CONTENT_TYPE ) else {
140
- return false ;
141
- } ;
142
-
143
- let Ok ( content_type) = content_type. to_str ( ) else {
144
- return false ;
145
- } ;
146
-
147
- let Ok ( mime) = content_type. parse :: < mime:: Mime > ( ) else {
148
- return false ;
149
- } ;
150
-
151
- let is_json_content_type = mime. type_ ( ) == "application"
152
- && ( mime. subtype ( ) == "json" || mime. suffix ( ) . is_some_and ( |name| name == "json" ) ) ;
153
-
154
- is_json_content_type
139
+ headers
140
+ . get ( header:: CONTENT_TYPE )
141
+ . and_then ( |content_type| content_type. to_str ( ) . ok ( ) )
142
+ . and_then ( |content_type| content_type. parse :: < mime:: Mime > ( ) . ok ( ) )
143
+ . is_some_and ( |mime| {
144
+ mime. type_ ( ) == "application"
145
+ && ( mime. subtype ( ) == "json" || mime. suffix ( ) . is_some_and ( |name| name == "json" ) )
146
+ } )
155
147
}
156
148
157
149
axum_core:: __impl_deref!( Json ) ;
You can’t perform that action at this time.
0 commit comments