| 2094 | // ---------------------------------------------------------------------- |
| 2095 | |
| 2096 | void 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 | |
| 2132 | void RenderingController::HandlePUT_mxnSelectedPosition(const httplib::Request& req, httplib::Response& res) const |
| 2133 | { |