@@ -459,11 +459,11 @@ pub struct ErrorTemplate {
459
459
nonce : String ,
460
460
}
461
461
462
- static HTML_CTYPE : HeaderValue = HeaderValue :: from_static ( "text/html;charset=utf-8" ) ;
462
+ static HTML_CONTENT_TYPE : HeaderValue = HeaderValue :: from_static ( "text/html;charset=utf-8" ) ;
463
463
464
464
pub struct Json < T : Serialize > ( pub T ) ;
465
465
466
- static JSON_CTYPE : HeaderValue = HeaderValue :: from_static ( "application/json;charset=utf-8" ) ;
466
+ static JSON_CONTENT_TYPE : HeaderValue = HeaderValue :: from_static ( "application/json;charset=utf-8" ) ;
467
467
468
468
fn infallible_json_serialize < T : Serialize > ( data : & T ) -> Vec < u8 > {
469
469
serde_json:: to_vec_pretty ( data) . unwrap_or_else ( |_| {
@@ -478,7 +478,7 @@ impl<T: Serialize> IntoResponse for Json<T> {
478
478
let body = infallible_json_serialize ( & self . 0 ) ;
479
479
(
480
480
StatusCode :: INTERNAL_SERVER_ERROR ,
481
- [ ( CONTENT_TYPE , JSON_CTYPE . clone ( ) ) ] ,
481
+ [ ( CONTENT_TYPE , JSON_CONTENT_TYPE . clone ( ) ) ] ,
482
482
body,
483
483
)
484
484
. into_response ( )
@@ -500,11 +500,13 @@ async fn error_middleware(
500
500
let error = failure. to_string ( ) ;
501
501
let status = resp. status ( ) ;
502
502
if json {
503
- resp. headers_mut ( ) . insert ( CONTENT_TYPE , JSON_CTYPE . clone ( ) ) ;
503
+ resp. headers_mut ( )
504
+ . insert ( CONTENT_TYPE , JSON_CONTENT_TYPE . clone ( ) ) ;
504
505
let error = ErrorSerialization { error } ;
505
506
( status, Json ( infallible_json_serialize ( & error) ) ) . into_response ( )
506
507
} else {
507
- resp. headers_mut ( ) . insert ( CONTENT_TYPE , HTML_CTYPE . clone ( ) ) ;
508
+ resp. headers_mut ( )
509
+ . insert ( CONTENT_TYPE , HTML_CONTENT_TYPE . clone ( ) ) ;
508
510
let error = ErrorTemplate {
509
511
error,
510
512
bd : state. bust_dir ,
@@ -522,8 +524,8 @@ pub struct Png(pub Vec<u8>);
522
524
523
525
impl IntoResponse for Png {
524
526
fn into_response ( self ) -> Response {
525
- static PNG_CTYPE : HeaderValue = HeaderValue :: from_static ( "image/png" ) ;
526
- let headers = [ ( CONTENT_TYPE , PNG_CTYPE . clone ( ) ) ] ;
527
+ static PNG_CONTENT_TYPE : HeaderValue = HeaderValue :: from_static ( "image/png" ) ;
528
+ let headers = [ ( CONTENT_TYPE , PNG_CONTENT_TYPE . clone ( ) ) ] ;
527
529
( headers, self . 0 ) . into_response ( )
528
530
}
529
531
}
0 commit comments