mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 06:10:44 +08:00
httpd: Add apiVersion to root handler and node information
This will help consumers of the httpd to check if they are on the right version of the API
This commit is contained in:
committed by
cloudhead
parent
a2189cabe4
commit
26b4ee064c
@@ -34,7 +34,9 @@ use crate::api::error::Error;
|
||||
use crate::cache::Cache;
|
||||
use crate::Options;
|
||||
|
||||
pub const VERSION: &str = env!("RADICLE_VERSION");
|
||||
pub const RADICLE_VERSION: &str = env!("RADICLE_VERSION");
|
||||
// This version has to be updated on every breaking change to the radicle-httpd API.
|
||||
pub const API_VERSION: &str = "0.1.0";
|
||||
|
||||
/// Identifier for sessions
|
||||
type SessionId = String;
|
||||
|
||||
@@ -11,7 +11,7 @@ use axum::routing::get;
|
||||
use axum::Router;
|
||||
use serde_json::json;
|
||||
|
||||
use crate::api::{Context, VERSION};
|
||||
use crate::api::{Context, API_VERSION, RADICLE_VERSION};
|
||||
|
||||
pub fn router(ctx: Context) -> Router {
|
||||
let root_router = Router::new()
|
||||
@@ -34,7 +34,8 @@ async fn root_handler(State(ctx): State<Context>) -> impl IntoResponse {
|
||||
let response = json!({
|
||||
"message": "Welcome!",
|
||||
"service": "radicle-httpd",
|
||||
"version": format!("{}-{}", VERSION, env!("GIT_HEAD")),
|
||||
"version": format!("{}-{}", RADICLE_VERSION, env!("GIT_HEAD")),
|
||||
"apiVersion": API_VERSION,
|
||||
"nid": ctx.profile.public_key,
|
||||
"path": "/api/v1",
|
||||
"links": [
|
||||
|
||||
@@ -12,7 +12,7 @@ use radicle::node::{policy, AliasStore, Handle, NodeId, DEFAULT_TIMEOUT};
|
||||
use radicle::Node;
|
||||
|
||||
use crate::api::error::Error;
|
||||
use crate::api::{self, Context, PoliciesQuery, VERSION};
|
||||
use crate::api::{self, Context, PoliciesQuery, RADICLE_VERSION};
|
||||
use crate::axum_extra::{Path, Query};
|
||||
|
||||
pub fn router(ctx: Context) -> Router {
|
||||
@@ -47,7 +47,7 @@ async fn node_handler(State(ctx): State<Context>) -> impl IntoResponse {
|
||||
};
|
||||
let response = json!({
|
||||
"id": node_id.to_string(),
|
||||
"version": format!("{}-{}", VERSION, env!("GIT_HEAD")),
|
||||
"version": format!("{}-{}", RADICLE_VERSION, env!("GIT_HEAD")),
|
||||
"config": config,
|
||||
"state": node_state,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user