🚧 wip: placeholder metrics page
parent
4307a199bc
commit
140434cf66
|
@ -205,6 +205,22 @@ async fn api_v1 (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument (level = "trace", skip (req, state))]
|
||||||
|
async fn metrics (
|
||||||
|
req: Request <Body>,
|
||||||
|
state: &Relay,
|
||||||
|
)
|
||||||
|
-> Result <Response <Body>, RequestError>
|
||||||
|
{
|
||||||
|
let mut s = String::with_capacity (4 * 1_024);
|
||||||
|
s.push_str ("# HELP forty_two Forty-two\n");
|
||||||
|
s.push_str ("# TYPE forty_two counter\n");
|
||||||
|
s.push_str ("forty_two 42\n");
|
||||||
|
|
||||||
|
Ok (Response::builder ()
|
||||||
|
.body (Body::from (s))?)
|
||||||
|
}
|
||||||
|
|
||||||
#[instrument (level = "trace", skip (req, state))]
|
#[instrument (level = "trace", skip (req, state))]
|
||||||
pub async fn handle (
|
pub async fn handle (
|
||||||
req: Request <Body>,
|
req: Request <Body>,
|
||||||
|
@ -225,6 +241,9 @@ pub async fn handle (
|
||||||
else if let Some (rest) = path_rest.strip_prefix ("api/") {
|
else if let Some (rest) = path_rest.strip_prefix ("api/") {
|
||||||
api_v1 (req, state, rest).await
|
api_v1 (req, state, rest).await
|
||||||
}
|
}
|
||||||
|
else if path_rest == "metrics" {
|
||||||
|
metrics (req, state).await
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
Ok (error_reply (StatusCode::NOT_FOUND, strings::UNKNOWN_API_VERSION)?)
|
Ok (error_reply (StatusCode::NOT_FOUND, strings::UNKNOWN_API_VERSION)?)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue