aboutsummaryrefslogtreecommitdiff
path: root/src/api/admin/router.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-12-05 15:28:57 +0100
committerAlex Auvolat <alex@adnab.me>2022-12-05 15:28:57 +0100
commit280d1be7b1fde13d23e47f75aa8acd2f90efb81f (patch)
tree5a74e5bdef1cef54360b2b3ca57a53bf1ce61ba2 /src/api/admin/router.rs
parent2065f011ca3f7c736feecffd108c89d3f8019e85 (diff)
downloadgarage-280d1be7b1fde13d23e47f75aa8acd2f90efb81f.tar.gz
garage-280d1be7b1fde13d23e47f75aa8acd2f90efb81f.zip
Refactor health check and add ability to return it in json
Diffstat (limited to 'src/api/admin/router.rs')
-rw-r--r--src/api/admin/router.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/api/admin/router.rs b/src/api/admin/router.rs
index 14411f75..6ffcc131 100644
--- a/src/api/admin/router.rs
+++ b/src/api/admin/router.rs
@@ -17,7 +17,9 @@ router_match! {@func
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Endpoint {
Options,
- Health,
+ Health {
+ format: Option<String>,
+ },
Metrics,
GetClusterStatus,
ConnectClusterNodes,
@@ -90,7 +92,7 @@ impl Endpoint {
let res = router_match!(@gen_path_parser (req.method(), path, query) [
OPTIONS _ => Options,
- GET "/health" => Health,
+ GET "/health" => Health (query_opt::format),
GET "/metrics" => Metrics,
GET "/v0/status" => GetClusterStatus,
POST "/v0/connect" => ConnectClusterNodes,
@@ -133,7 +135,7 @@ impl Endpoint {
/// Get the kind of authorization which is required to perform the operation.
pub fn authorization_type(&self) -> Authorization {
match self {
- Self::Health => Authorization::None,
+ Self::Health { .. } => Authorization::None,
Self::Metrics => Authorization::MetricsToken,
_ => Authorization::AdminToken,
}
@@ -141,6 +143,7 @@ impl Endpoint {
}
generateQueryParameters! {
+ "format" => format,
"id" => id,
"search" => search,
"globalAlias" => global_alias,