Skip to content

Commit

Permalink
Set plain/text Content-Type (#496)
Browse files Browse the repository at this point in the history
Co-authored-by: Mattias Eriksson <[email protected]>
  • Loading branch information
snaggen and snaggen authored Jul 10, 2024
1 parent f84efc4 commit 6b603f9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions metrics-exporter-prometheus/src/exporter/http_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::net::SocketAddr;
use http_body_util::Full;
use hyper::{
body::{self, Bytes, Incoming},
header::{HeaderValue, CONTENT_TYPE},
server::conn::http1::Builder as HyperHttpBuilder,
service::service_fn,
Request, Response, StatusCode,
Expand Down Expand Up @@ -69,10 +70,12 @@ impl HttpListeningExporter {
req: &Request<Incoming>,
) -> Response<Full<Bytes>> {
if is_allowed {
Response::new(match req.uri().path() {
let mut response = Response::new(match req.uri().path() {
"/health" => "OK".into(),
_ => handle.render().into(),
})
});
response.headers_mut().append(CONTENT_TYPE, HeaderValue::from_static("text/plain"));
response
} else {
Self::new_forbidden_response()
}
Expand Down

0 comments on commit 6b603f9

Please sign in to comment.