mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 18:20:30 +08:00
Migrate /v1/, /v1/node routes to heartwood
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
use axum::response::IntoResponse;
|
||||
use axum::routing::get;
|
||||
use axum::{Extension, Json, Router};
|
||||
use serde_json::json;
|
||||
|
||||
use radicle::node::NodeId;
|
||||
|
||||
use crate::api::Context;
|
||||
|
||||
pub fn router(ctx: Context) -> Router {
|
||||
let node_id = ctx.profile.public_key;
|
||||
|
||||
Router::new()
|
||||
.route("/node", get(node_handler))
|
||||
.layer(Extension(node_id))
|
||||
}
|
||||
|
||||
/// Return the node id for the node identity.
|
||||
/// `GET /node`
|
||||
async fn node_handler(Extension(node_id): Extension<NodeId>) -> impl IntoResponse {
|
||||
let response = json!({
|
||||
"id": node_id.to_string(),
|
||||
});
|
||||
|
||||
Json(response)
|
||||
}
|
||||
Reference in New Issue
Block a user