Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/invoice/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ pub struct MissingParcelsResponse {
pub missing: Vec<Label>,
}

#[derive(Deserialize, Serialize)]
pub struct HealthResponse {
pub status: String,
pub version: String,
}

/// A string error message returned from the server
#[derive(Debug, Serialize, Deserialize)]
pub struct ErrorResponse {
Expand Down
3 changes: 2 additions & 1 deletion src/invoice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ pub(crate) use api::DeviceAuthorizationExtraFields;
pub(crate) use api::LoginParams;
#[doc(inline)]
pub use api::{
ErrorResponse, InvoiceCreateResponse, KeyOptions, MissingParcelsResponse, QueryOptions,
ErrorResponse, HealthResponse, InvoiceCreateResponse, KeyOptions, MissingParcelsResponse,
QueryOptions,
};
#[doc(inline)]
pub use bindle_spec::BindleSpec;
Expand Down
9 changes: 7 additions & 2 deletions src/server/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::Arc;

use warp::Filter;

use crate::{server::filters, signature::KeyRing};
use crate::{invoice::HealthResponse, server::filters, signature::KeyRing};

/// A helper function that aggregates all routes into a complete API filter. If you only wish to
/// serve specific endpoints or versions, you can assemble them with the individual submodules
Expand All @@ -22,7 +22,12 @@ where
Authn: crate::authn::Authenticator + Clone + Send + Sync + 'static,
Authz: crate::authz::Authorizer + Clone + Send + Sync + 'static,
{
let health = warp::path("healthz").map(|| "OK");
let health = warp::path("healthz").map(|| {
warp::reply::json(&HealthResponse {
status: "OK".to_string(),
version: env!("CARGO_PKG_VERSION").to_string(),
})
});

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