Skip to content

Commit 9376c32

Browse files
Rename content types
1 parent 810add7 commit 9376c32

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/main.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -459,11 +459,11 @@ pub struct ErrorTemplate {
459459
nonce: String,
460460
}
461461

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");
463463

464464
pub struct Json<T: Serialize>(pub T);
465465

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");
467467

468468
fn infallible_json_serialize<T: Serialize>(data: &T) -> Vec<u8> {
469469
serde_json::to_vec_pretty(data).unwrap_or_else(|_| {
@@ -478,7 +478,7 @@ impl<T: Serialize> IntoResponse for Json<T> {
478478
let body = infallible_json_serialize(&self.0);
479479
(
480480
StatusCode::INTERNAL_SERVER_ERROR,
481-
[(CONTENT_TYPE, JSON_CTYPE.clone())],
481+
[(CONTENT_TYPE, JSON_CONTENT_TYPE.clone())],
482482
body,
483483
)
484484
.into_response()
@@ -500,11 +500,13 @@ async fn error_middleware(
500500
let error = failure.to_string();
501501
let status = resp.status();
502502
if json {
503-
resp.headers_mut().insert(CONTENT_TYPE, JSON_CTYPE.clone());
503+
resp.headers_mut()
504+
.insert(CONTENT_TYPE, JSON_CONTENT_TYPE.clone());
504505
let error = ErrorSerialization { error };
505506
(status, Json(infallible_json_serialize(&error))).into_response()
506507
} else {
507-
resp.headers_mut().insert(CONTENT_TYPE, HTML_CTYPE.clone());
508+
resp.headers_mut()
509+
.insert(CONTENT_TYPE, HTML_CONTENT_TYPE.clone());
508510
let error = ErrorTemplate {
509511
error,
510512
bd: state.bust_dir,
@@ -522,8 +524,8 @@ pub struct Png(pub Vec<u8>);
522524

523525
impl IntoResponse for Png {
524526
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())];
527529
(headers, self.0).into_response()
528530
}
529531
}

0 commit comments

Comments
 (0)