Skip to content

Commit 4830434

Browse files
Use with_body instead of with_body_text_plain for JSON responses
The with_body_text_plain method sets Content-Type to text/plain, overriding the APPLICATION_JSON type set by with_content_type. Replace all 6 occurrences in request signing endpoints with with_body which preserves the previously set Content-Type. Closes #424
1 parent 5817deb commit 4830434

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

crates/trusted-server-core/src/request_signing/endpoints.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub fn handle_trusted_server_discovery(
4848

4949
Ok(Response::from_status(200)
5050
.with_content_type(fastly::mime::APPLICATION_JSON)
51-
.with_body_text_plain(&json))
51+
.with_body(json))
5252
}
5353

5454
#[derive(Debug, Deserialize, Serialize)]
@@ -118,7 +118,7 @@ pub fn handle_verify_signature(
118118

119119
Ok(Response::from_status(200)
120120
.with_content_type(fastly::mime::APPLICATION_JSON)
121-
.with_body_text_plain(&response_json))
121+
.with_body(response_json))
122122
}
123123

124124
#[derive(Debug, Deserialize, Serialize)]
@@ -199,7 +199,7 @@ pub fn handle_rotate_key(
199199

200200
Ok(Response::from_status(200)
201201
.with_content_type(fastly::mime::APPLICATION_JSON)
202-
.with_body_text_plain(&response_json))
202+
.with_body(response_json))
203203
}
204204
Err(e) => {
205205
let response = RotateKeyResponse {
@@ -220,7 +220,7 @@ pub fn handle_rotate_key(
220220

221221
Ok(Response::from_status(500)
222222
.with_content_type(fastly::mime::APPLICATION_JSON)
223-
.with_body_text_plain(&response_json))
223+
.with_body(response_json))
224224
}
225225
}
226226
}
@@ -305,7 +305,7 @@ pub fn handle_deactivate_key(
305305

306306
Ok(Response::from_status(200)
307307
.with_content_type(fastly::mime::APPLICATION_JSON)
308-
.with_body_text_plain(&response_json))
308+
.with_body(response_json))
309309
}
310310
Err(e) => {
311311
let response = DeactivateKeyResponse {
@@ -329,7 +329,7 @@ pub fn handle_deactivate_key(
329329

330330
Ok(Response::from_status(500)
331331
.with_content_type(fastly::mime::APPLICATION_JSON)
332-
.with_body_text_plain(&response_json))
332+
.with_body(response_json))
333333
}
334334
}
335335
}

0 commit comments

Comments
 (0)