mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-11 23:10:34 +08:00
httpd: Add endpoint with tracking information
This allows us to check which projects are really tracked by the node and which aren't and with which scopes and policies.
This commit is contained in:
committed by
cloudhead
parent
c197bc8763
commit
80c1bb5b22
@@ -4,7 +4,7 @@ use axum::routing::get;
|
||||
use axum::{Json, Router};
|
||||
use serde_json::json;
|
||||
|
||||
use radicle::node::Handle;
|
||||
use radicle::node::{tracking, Handle};
|
||||
use radicle::Node;
|
||||
|
||||
use crate::api::error::Error;
|
||||
@@ -13,6 +13,7 @@ use crate::api::Context;
|
||||
pub fn router(ctx: Context) -> Router {
|
||||
Router::new()
|
||||
.route("/node", get(node_handler))
|
||||
.route("/node/tracking/repos", get(node_tracking_repos_handler))
|
||||
.with_state(ctx)
|
||||
}
|
||||
|
||||
@@ -41,3 +42,20 @@ async fn node_handler(State(ctx): State<Context>) -> impl IntoResponse {
|
||||
|
||||
Ok::<_, Error>(Json(response))
|
||||
}
|
||||
|
||||
/// Return local tracking repos information.
|
||||
/// `GET /node/tracking/repos`
|
||||
async fn node_tracking_repos_handler(State(ctx): State<Context>) -> impl IntoResponse {
|
||||
let tracking = ctx.profile.tracking()?;
|
||||
let mut repos = Vec::new();
|
||||
|
||||
for tracking::Repo { id, scope, policy } in tracking.repo_policies()? {
|
||||
repos.push(json!({
|
||||
"id": id,
|
||||
"scope": scope,
|
||||
"policy": policy,
|
||||
}));
|
||||
}
|
||||
|
||||
Ok::<_, Error>(Json(repos))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user