瀏覽代碼

Add version url to quorum api (#2817)

Dani Mehrjerdi 4 月之前
父節點
當前提交
bce96b5ee5
共有 3 個文件被更改,包括 8 次插入2 次删除
  1. 1 1
      apps/quorum/Cargo.lock
  2. 1 1
      apps/quorum/Cargo.toml
  3. 6 0
      apps/quorum/src/api.rs

+ 1 - 1
apps/quorum/Cargo.lock

@@ -2760,7 +2760,7 @@ dependencies = [
 
 [[package]]
 name = "quorum"
-version = "0.2.1"
+version = "0.2.2"
 dependencies = [
  "anyhow",
  "axum",

+ 1 - 1
apps/quorum/Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = "quorum"
-version = "0.2.1"
+version = "0.2.2"
 edition = "2021"
 
 [dependencies]

+ 6 - 0
apps/quorum/src/api.rs

@@ -4,6 +4,7 @@ use axum::{
     Json, Router,
 };
 use axum_prometheus::{EndpointLabel, PrometheusMetricLayerBuilder};
+use clap::crate_version;
 use secp256k1::{
     ecdsa::{RecoverableSignature, RecoveryId},
     Message, Secp256k1,
@@ -27,6 +28,10 @@ use crate::{
 
 pub type Payload<'a> = &'a RawMessage;
 
+async fn root() -> String {
+    format!("Quorum API {}", crate_version!())
+}
+
 pub async fn run(listen_address: SocketAddr, state: State) -> anyhow::Result<()> {
     tracing::info!("Starting server...");
 
@@ -38,6 +43,7 @@ pub async fn run(listen_address: SocketAddr, state: State) -> anyhow::Result<()>
         .build_pair();
 
     let routes = Router::new()
+        .route("/", get(root))
         .route("/live", get(|| async { "OK" }))
         .route("/observation", post(post_observation))
         .route("/ws", get(ws_route_handler))