Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions crates/trusted-server-core/src/request_signing/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub fn handle_trusted_server_discovery(

Ok(Response::from_status(200)
.with_content_type(fastly::mime::APPLICATION_JSON)
.with_body_text_plain(&json))
.with_body(json))
}

#[derive(Debug, Deserialize, Serialize)]
Expand Down Expand Up @@ -118,7 +118,7 @@ pub fn handle_verify_signature(

Ok(Response::from_status(200)
.with_content_type(fastly::mime::APPLICATION_JSON)
.with_body_text_plain(&response_json))
.with_body(response_json))
}

#[derive(Debug, Deserialize, Serialize)]
Expand Down Expand Up @@ -199,7 +199,7 @@ pub fn handle_rotate_key(

Ok(Response::from_status(200)
.with_content_type(fastly::mime::APPLICATION_JSON)
.with_body_text_plain(&response_json))
.with_body(response_json))
}
Err(e) => {
let response = RotateKeyResponse {
Expand All @@ -220,7 +220,7 @@ pub fn handle_rotate_key(

Ok(Response::from_status(500)
.with_content_type(fastly::mime::APPLICATION_JSON)
.with_body_text_plain(&response_json))
.with_body(response_json))
}
}
}
Expand Down Expand Up @@ -305,7 +305,7 @@ pub fn handle_deactivate_key(

Ok(Response::from_status(200)
.with_content_type(fastly::mime::APPLICATION_JSON)
.with_body_text_plain(&response_json))
.with_body(response_json))
}
Err(e) => {
let response = DeactivateKeyResponse {
Expand All @@ -329,7 +329,7 @@ pub fn handle_deactivate_key(

Ok(Response::from_status(500)
.with_content_type(fastly::mime::APPLICATION_JSON)
.with_body_text_plain(&response_json))
.with_body(response_json))
}
}
}
Expand Down Expand Up @@ -366,6 +366,11 @@ mod tests {
let mut resp =
handle_verify_signature(&settings, req).expect("should handle verification request");
assert_eq!(resp.get_status(), StatusCode::OK);
assert_eq!(
resp.get_content_type(),
Some(fastly::mime::APPLICATION_JSON),
"should return application/json content type"
);

// Parse response
let resp_body = resp.take_body_str();
Expand Down Expand Up @@ -403,6 +408,11 @@ mod tests {
let mut resp =
handle_verify_signature(&settings, req).expect("should handle verification request");
assert_eq!(resp.get_status(), StatusCode::OK);
assert_eq!(
resp.get_content_type(),
Some(fastly::mime::APPLICATION_JSON),
"should return application/json content type"
);

// Parse response
let resp_body = resp.take_body_str();
Expand Down Expand Up @@ -584,6 +594,11 @@ mod tests {
match result {
Ok(mut resp) => {
assert_eq!(resp.get_status(), StatusCode::OK);
assert_eq!(
resp.get_content_type(),
Some(fastly::mime::APPLICATION_JSON),
"should return application/json content type"
);
let body = resp.take_body_str();

// Parse the discovery document
Expand Down
Loading