MCPcopy Create free account
hub / github.com/MITK/MITK / HandleGET_mxnSelectedPosition

Method HandleGET_mxnSelectedPosition

Modules/RESTAPI/src/mitkRenderingController.cpp:2096–2130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2094// ----------------------------------------------------------------------
2095
2096void RenderingController::HandleGET_mxnSelectedPosition(const httplib::Request& req, httplib::Response& res) const
2097{
2098 const auto id = ReadRequiredPathParam(req, "id");
2099
2100 if (!IsValidMxNWindowId(id))
2101 {
2102 const auto error = ErrorResponse::InvalidRequest(
2103 "Malformed MxN window id '" + id + "'. Expected pattern: <prefix>__<bare> with URL-segment-safe characters.",
2104 req.path);
2105 this->SendErrorResponse(res, 400, error);
2106 return;
2107 }
2108
2109 if (m_RenderWindowBridge == nullptr || !m_RenderWindowBridge->HasMxNSelectedPositionGetter())
2110 {
2111 const auto error = ErrorResponse::RenderWindowNotAvailable(req.path);
2112 this->SendErrorResponse(res, 503, error);
2113 return;
2114 }
2115
2116 SelectedPositionInfo info;
2117 try
2118 {
2119 info = m_RenderWindowBridge->GetMxNSelectedPosition(id);
2120 }
2121 catch (const std::exception& e)
2122 {
2123 const auto [status, payload] = MapBridgeException(e, req.path);
2124 this->SendErrorResponse(res, status, payload);
2125 return;
2126 }
2127
2128 res.status = 200;
2129 res.set_content(SerializeSelectedPositionInfoToJson(info).dump(), "application/json");
2130}
2131
2132void RenderingController::HandlePUT_mxnSelectedPosition(const httplib::Request& req, httplib::Response& res) const
2133{

Calls 5

SendErrorResponseMethod · 0.95
IsValidMxNWindowIdFunction · 0.85