From 75ed1f954eac0f6aca08512b47c3cb462dfb4a5d Mon Sep 17 00:00:00 2001 From: leonarski_f Date: Mon, 23 Mar 2026 21:41:09 +0100 Subject: [PATCH] Work in progress --- broker/JFJochBrokerHttp.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/broker/JFJochBrokerHttp.cpp b/broker/JFJochBrokerHttp.cpp index 5f1da746..5861c240 100644 --- a/broker/JFJochBrokerHttp.cpp +++ b/broker/JFJochBrokerHttp.cpp @@ -18,6 +18,26 @@ using namespace org::openapitools::server::model; namespace { + template + static bool fromStringValue(const std::string& s, T& out) { + std::istringstream is(s); + is >> out; + return !is.fail() && is.eof(); + } + + template <> + static bool fromStringValue(const std::string& s, std::string& out) { + out = s; + return true; + } + + template <> + static bool fromStringValue(const std::string& s, bool& out) { + if (s == "true" || s == "1") { out = true; return true; } + if (s == "false" || s == "0") { out = false; return true; } + return false; + } + template std::optional query_optional(const httplib::Request& req, const char* name) { if (!req.has_param(name)) @@ -82,8 +102,6 @@ std::pair JFJochBrokerHttp::handleParsingException(const std:: throw; } catch (nlohmann::detail::exception &e) { return {400, e.what()}; - } catch (ValidationException &e) { - return {400, e.what()}; } catch (std::exception &e) { return {500, e.what()}; }