| 1203 | } |
| 1204 | |
| 1205 | void DataStorageController::HandleGET_nodes_uid(const httplib::Request& req, httplib::Response& res) |
| 1206 | { |
| 1207 | if (!m_Bridge.HasDataStorage()) |
| 1208 | { |
| 1209 | this->SendErrorResponse(res, 503, ErrorResponse::DataStorageNotAvailable(req.path)); |
| 1210 | return; |
| 1211 | } |
| 1212 | |
| 1213 | const std::string uid = req.path_params.at("uid"); |
| 1214 | if (!ValidateUid(uid)) |
| 1215 | { |
| 1216 | this->SendErrorResponse(res, 400, ErrorResponse::InvalidRequest("Invalid UID format", req.path)); |
| 1217 | return; |
| 1218 | } |
| 1219 | |
| 1220 | auto node = m_Bridge.GetNode(uid); |
| 1221 | if (!node.has_value()) |
| 1222 | { |
| 1223 | this->SendErrorResponse(res, 404, ErrorResponse::NodeNotFound(uid, req.path)); |
| 1224 | return; |
| 1225 | } |
| 1226 | |
| 1227 | // Get available contexts for this node |
| 1228 | auto availableContexts = m_Bridge.GetNodeAvailableContexts(uid); |
| 1229 | |
| 1230 | nlohmann::json response; |
| 1231 | response["data"] = node.value(); |
| 1232 | if (availableContexts.has_value()) |
| 1233 | { |
| 1234 | response["meta"]["available_contexts"] = availableContexts.value(); |
| 1235 | } |
| 1236 | |
| 1237 | this->SendJsonResponse(res, 200, response); |
| 1238 | } |
| 1239 | |
| 1240 | void DataStorageController::HandlePATCH_nodes_uid(const httplib::Request& req, httplib::Response& res) |
| 1241 | { |