diff --git a/metrics.rs b/metrics.rs index b33ad02..d3b2c2f 100644 --- a/metrics.rs +++ b/metrics.rs @@ -575,18 +575,14 @@ fn json_response(status: u16, body: &str) -> Response> { } fn text_response(status: u16, content_type: &str, body: String) -> Response> { - match Response::builder() + Response::builder() .status(status) .header("Content-Type", content_type) .header("Connection", "close") - .body(Full::new(Bytes::from(body))) - { - Ok(response) => response, - Err(err) => { - tracing::error!(error = %err, "failed to build text response"); - Response::new(Full::new(Bytes::from_static(b"response build failed"))) - } - } + .body(Full::new(Bytes::from(body))).unwrap_or_else(|err| { + tracing::error!(error = %err, "failed to build text response"); + Response::new(Full::new(Bytes::from_static(b"response build failed"))) + }) } async fn handle_request(req: Request) -> Result>, Infallible> {