Skip to content

Commit 3308896

Browse files
committed
Site: add compression to graph/graphs pages
1 parent afe1fe9 commit 3308896

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

site/src/server.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ impl Server {
137137
async fn handle_fallible_get_async<F, R, S, E>(
138138
&self,
139139
req: &Request,
140+
compression: &Option<BrotliEncoderParams>,
140141
handler: F,
141142
) -> Result<Response, ServerError>
142143
where
@@ -155,7 +156,7 @@ impl Server {
155156
.header_typed(ContentType::json())
156157
.header_typed(CacheControl::new().with_no_cache().with_no_store());
157158
let body = serde_json::to_vec(&result).unwrap();
158-
response.body(hyper::Body::from(body)).unwrap()
159+
maybe_compressed_response(response, body, compression)
159160
}
160161
Err(err) => http::Response::builder()
161162
.status(StatusCode::INTERNAL_SERVER_ERROR)
@@ -369,13 +370,17 @@ async fn serve_req(server: Server, req: Request) -> Result<Response, ServerError
369370
"/perf/graph" => {
370371
let query = check!(parse_query_string(req.uri()));
371372
return server
372-
.handle_fallible_get_async(&req, |c| request_handlers::handle_graph(query, c))
373+
.handle_fallible_get_async(&req, &compression, |c| {
374+
request_handlers::handle_graph(query, c)
375+
})
373376
.await;
374377
}
375378
"/perf/graphs" => {
376379
let query = check!(parse_query_string(req.uri()));
377380
return server
378-
.handle_fallible_get_async(&req, |c| request_handlers::handle_graphs(query, c))
381+
.handle_fallible_get_async(&req, &compression, |c| {
382+
request_handlers::handle_graphs(query, c)
383+
})
379384
.await;
380385
}
381386
"/perf/metrics" => {

0 commit comments

Comments
 (0)