Migrate /v1/, /v1/node routes to heartwood

Signed-off-by: xphoniex <dj.2dixx@gmail.com>
This commit is contained in:
xphoniex
2022-11-30 13:06:03 +00:00
parent ef1c331cb6
commit ae2a35abb9
6 changed files with 275 additions and 15 deletions
+26
View File
@@ -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)
}