mirror of https://github.com/telemt/telemt.git
set content type on metrics 404 responses
This commit is contained in:
parent
e35d69c61f
commit
df37fab2fc
|
|
@ -19,6 +19,7 @@ use crate::stats::Stats;
|
||||||
use crate::stats::beobachten::BeobachtenStore;
|
use crate::stats::beobachten::BeobachtenStore;
|
||||||
use crate::transport::{ListenOptions, create_listener};
|
use crate::transport::{ListenOptions, create_listener};
|
||||||
|
|
||||||
|
/// Serves the Prometheus metrics and beobachten plaintext endpoints.
|
||||||
pub async fn serve(
|
pub async fn serve(
|
||||||
port: u16,
|
port: u16,
|
||||||
listen: Option<String>,
|
listen: Option<String>,
|
||||||
|
|
@ -205,6 +206,7 @@ async fn handle<B>(
|
||||||
|
|
||||||
let resp = Response::builder()
|
let resp = Response::builder()
|
||||||
.status(StatusCode::NOT_FOUND)
|
.status(StatusCode::NOT_FOUND)
|
||||||
|
.header("content-type", "text/plain; charset=utf-8")
|
||||||
.body(Full::new(Bytes::from("Not Found\n")))
|
.body(Full::new(Bytes::from("Not Found\n")))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
Ok(resp)
|
Ok(resp)
|
||||||
|
|
@ -2782,5 +2784,9 @@ mod tests {
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(resp404.status(), StatusCode::NOT_FOUND);
|
assert_eq!(resp404.status(), StatusCode::NOT_FOUND);
|
||||||
|
assert_eq!(
|
||||||
|
resp404.headers().get("content-type").unwrap(),
|
||||||
|
"text/plain; charset=utf-8"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue