41fb17a31b
* WIP adding derive(ToSchema) * Derive ToSchema for more types * ContractBuildInformation on /nym_contracts_detailed * rustfmt * Add cfg_attr * A bunch of annotations * Compiles with utoipa 5.2 * WIP * Post rebase fixes * Gitattributes to ignore .sqlx diffs * generate Sqlx schema files * Improvements * Move ecash schema out of ecash crate * Move redocly config to nym-api/ * Move redocly config to nym-api/ * Remove ErrorResponse * Move generated openapi spec to .gitignore * Include BSL licence * Remove utoipa from ecash toml file * Remove placeholder annotations * Chain-watcher rebase changes * Update licence info * Treat Scalar as String in OpenAPI
35 lines
1.0 KiB
Rust
35 lines
1.0 KiB
Rust
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
use crate::node::http::state::AppState;
|
|
use axum::extract::{Query, State};
|
|
use nym_http_api_common::{FormattedResponse, OutputParams};
|
|
use nym_node_requests::api::v1::health::models::NodeHealth;
|
|
|
|
/// Returns health status of this node.
|
|
#[utoipa::path(
|
|
get,
|
|
path = "/health",
|
|
context_path = "/api/v1",
|
|
tag = "Health",
|
|
responses(
|
|
(status = 200, content(
|
|
(Vec<NodeHealth> = "application/json"),
|
|
(Vec<NodeHealth> = "application/yaml")
|
|
), description = "the api is available and healthy")
|
|
),
|
|
params(OutputParams)
|
|
)]
|
|
pub(crate) async fn root_health(
|
|
Query(output): Query<OutputParams>,
|
|
State(state): State<AppState>,
|
|
) -> HealthResponse {
|
|
let output = output.output.unwrap_or_default();
|
|
let uptime = state.startup_time.elapsed();
|
|
let health = NodeHealth::new_healthy(uptime);
|
|
|
|
output.to_response(health)
|
|
}
|
|
|
|
pub type HealthResponse = FormattedResponse<NodeHealth>;
|