🚧 wip: placeholder metrics page

main
_ 2022-07-27 17:31:28 -05:00
parent 4307a199bc
commit 140434cf66
1 changed files with 19 additions and 0 deletions

View File

@ -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))]
pub async fn handle (
req: Request <Body>,
@ -225,6 +241,9 @@ pub async fn handle (
else if let Some (rest) = path_rest.strip_prefix ("api/") {
api_v1 (req, state, rest).await
}
else if path_rest == "metrics" {
metrics (req, state).await
}
else {
Ok (error_reply (StatusCode::NOT_FOUND, strings::UNKNOWN_API_VERSION)?)
}