Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.

Commit b05065a

Browse files
committed
feat(healthz): add version
Signed-off-by: Frank Yang <yangpoan@gmail.com>
1 parent 87fe10d commit b05065a

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ maintenance = { status = "actively-developed" }
2727

2828
[features]
2929
default = ["server", "client", "caching", "test-tools", "native-tls"]
30-
server = ["warp", "openid", "hyper", "mime", "either", "_common"]
30+
server = ["clap", "warp", "openid", "hyper", "mime", "either", "_common"]
3131
client = ["mime_guess", "dirs", "time", "async-compression", "tokio-tar", "_common"]
3232
# Internal use only feature that groups all of the optional deps we need for both server and client
3333
_common = ["providers", "tokio/full", "tokio-util", "oauth2", "reqwest"]

src/server/routes.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
use std::sync::Arc;
22

3+
use serde::{Deserialize, Serialize};
34
use warp::Filter;
45

56
use crate::{server::filters, signature::KeyRing};
67

8+
#[derive(Deserialize, Serialize)]
9+
pub struct HealthStatus {
10+
status: String,
11+
version: String,
12+
}
13+
714
/// A helper function that aggregates all routes into a complete API filter. If you only wish to
815
/// serve specific endpoints or versions, you can assemble them with the individual submodules
916
pub fn api<P, I, Authn, Authz, S>(
@@ -22,7 +29,12 @@ where
2229
Authn: crate::authn::Authenticator + Clone + Send + Sync + 'static,
2330
Authz: crate::authz::Authorizer + Clone + Send + Sync + 'static,
2431
{
25-
let health = warp::path("healthz").map(|| "OK");
32+
let health = warp::path("healthz").map(|| {
33+
warp::reply::json(&HealthStatus {
34+
status: "Ok".to_string(),
35+
version: clap::crate_version!().to_string(),
36+
})
37+
});
2638

2739
// Use an Arc to avoid a possibly expensive clone of the keyring on every API call
2840
let wrapped_keyring = Arc::new(keyring);

0 commit comments

Comments
 (0)