diff --git a/agent_api_rest/postman/ssi-agent.postman_collection.json b/agent_api_rest/postman/ssi-agent.postman_collection.json index 3f6764c9..f8001fc9 100644 --- a/agent_api_rest/postman/ssi-agent.postman_collection.json +++ b/agent_api_rest/postman/ssi-agent.postman_collection.json @@ -1,9 +1,9 @@ { "info": { - "_postman_id": "53b46e18-de7f-4973-8304-8238844a71ce", + "_postman_id": "91fc7356-1c5b-4b30-ac7b-e320477cfbbf", "name": "ssi-agent", "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json", - "_exporter_id": "24972330" + "_exporter_id": "30650915" }, "item": [ { @@ -190,8 +190,7 @@ "header": [ { "key": "Authorization", - "value": "Bearer {{ACCESS_TOKEN}}", - "type": "text" + "value": "Bearer {{ACCESS_TOKEN}}" } ], "body": { @@ -286,6 +285,20 @@ "response": [] } ] + }, + { + "name": "metrics", + "item": [ + { + "name": "health", + "request": { + "method": "GET", + "header": [], + "url": "http://{{HOST}}/health" + }, + "response": [] + } + ] } ], "event": [ diff --git a/agent_api_rest/src/lib.rs b/agent_api_rest/src/lib.rs index 9e0d489e..451db879 100644 --- a/agent_api_rest/src/lib.rs +++ b/agent_api_rest/src/lib.rs @@ -1,4 +1,5 @@ mod issuance; +mod metrics; mod verification; use agent_issuance::state::IssuanceState; @@ -21,6 +22,7 @@ use issuance::credential_issuer::{ }; use issuance::credentials::{credentials, get_credentials}; use issuance::offers::offers; +use metrics::health; use tower_http::trace::TraceLayer; use tracing::{info_span, Span}; use verification::{ @@ -66,6 +68,8 @@ pub fn app(state: ApplicationState) -> Router { // SIOPv2 .route(&path("/request/:request_id"), get(request)) .route(&path("/redirect"), post(redirect)) + // Monitoring + .route(&path("/health"), get(health)) // Trace layer .layer( TraceLayer::new_for_http() diff --git a/agent_api_rest/src/metrics.rs b/agent_api_rest/src/metrics.rs new file mode 100644 index 00000000..8c38c81d --- /dev/null +++ b/agent_api_rest/src/metrics.rs @@ -0,0 +1,9 @@ +use axum::Json; +use serde_json::{json, Value}; + +#[axum_macros::debug_handler] +pub(crate) async fn health() -> Json { + Json(json!({ + "status": "UP" + })) +}