Skip to content

Commit 8999148

Browse files
committed
properly add vary header for alternative content-types
1 parent d222b38 commit 8999148

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

application/src/response.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ impl ApiResponse {
4444
}
4545
}
4646

47-
#[inline]
4847
pub fn new_serialized(body: impl serde::Serialize) -> Self {
4948
let accept_header = ACCEPT_HEADER.try_with(|h| h.clone()).ok().flatten();
5049

@@ -95,10 +94,13 @@ impl ApiResponse {
9594
Self {
9695
body,
9796
status: axum::http::StatusCode::OK,
98-
headers: axum::http::HeaderMap::from_iter([(
99-
axum::http::header::CONTENT_TYPE,
100-
content_type,
101-
)]),
97+
headers: axum::http::HeaderMap::from_iter([
98+
(axum::http::header::CONTENT_TYPE, content_type),
99+
(
100+
axum::http::header::VARY,
101+
axum::http::HeaderValue::from_static("Accept"),
102+
),
103+
]),
102104
}
103105
}
104106

0 commit comments

Comments
 (0)