Skip to content

Commit

Permalink
feat: add /health endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-mader committed May 8, 2024
1 parent fcd11b0 commit e3fcf0e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
21 changes: 17 additions & 4 deletions agent_api_rest/postman/ssi-agent.postman_collection.json
Original file line number Diff line number Diff line change
@@ -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": [
{
Expand Down Expand Up @@ -190,8 +190,7 @@
"header": [
{
"key": "Authorization",
"value": "Bearer {{ACCESS_TOKEN}}",
"type": "text"
"value": "Bearer {{ACCESS_TOKEN}}"
}
],
"body": {
Expand Down Expand Up @@ -286,6 +285,20 @@
"response": []
}
]
},
{
"name": "metrics",
"item": [
{
"name": "health",
"request": {
"method": "GET",
"header": [],
"url": "http://{{HOST}}/health"
},
"response": []
}
]
}
],
"event": [
Expand Down
4 changes: 4 additions & 0 deletions agent_api_rest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod issuance;
mod metrics;
mod verification;

use agent_issuance::state::IssuanceState;
Expand All @@ -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::{
Expand Down Expand Up @@ -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()
Expand Down
9 changes: 9 additions & 0 deletions agent_api_rest/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use axum::Json;
use serde_json::{json, Value};

#[axum_macros::debug_handler]
pub(crate) async fn health() -> Json<Value> {
Json(json!({
"status": "UP"
}))
}

0 comments on commit e3fcf0e

Please sign in to comment.