feat: add node register endpoint and fabric create-target/connect APIs
- POST /api/graph/nodes/{id}/register: register manually-started node with control port
- POST /api/fabric/create-target: add_writer + poll for target_info
- POST /api/fabric/connect: auto-propagate target_info to initiator
- fabric-bridge: auto-fetch target_info from remote target via HTTP
This commit is contained in:
@@ -321,6 +321,26 @@ static void handle_request(const std::string& method, const std::string& path,
|
|||||||
} else {
|
} else {
|
||||||
error_resp(500, "Failed to send command to node");
|
error_resp(500, "Failed to send command to node");
|
||||||
}
|
}
|
||||||
|
} else if (path.find("/api/graph/nodes/") == 0 && path.find("/register") != std::string::npos && method == "POST") {
|
||||||
|
auto prefix = std::string("/api/graph/nodes/");
|
||||||
|
auto suffix_start = path.find("/register");
|
||||||
|
auto node_id = path.substr(prefix.length(), suffix_start - prefix.length());
|
||||||
|
|
||||||
|
if (!req_body.contains("port")) {
|
||||||
|
error_resp(400, "Missing port");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto control_port = static_cast<uint16_t>(req_body["port"].get<int>());
|
||||||
|
cc.register_node(node_id, control_port);
|
||||||
|
|
||||||
|
auto* node = graph.get_node_mut(node_id);
|
||||||
|
if (node) {
|
||||||
|
node->control_port = control_port;
|
||||||
|
node->state = NodeState::Running;
|
||||||
|
}
|
||||||
|
|
||||||
|
ok({{"node_id", node_id}, {"control_port", control_port}});
|
||||||
} else if (path == "/api/fabric/create-target" && method == "POST") {
|
} else if (path == "/api/fabric/create-target" && method == "POST") {
|
||||||
if (!req_body.contains("node_id")) {
|
if (!req_body.contains("node_id")) {
|
||||||
error_resp(400, "Missing node_id");
|
error_resp(400, "Missing node_id");
|
||||||
|
|||||||
Reference in New Issue
Block a user