generated from Sithas/conan_template
Post Diary
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/url.hpp>
|
||||
#include <mysqlx/xdevapi.h>
|
||||
#include <mysqlx/common/api.h>
|
||||
|
||||
@@ -157,6 +160,8 @@ public:
|
||||
Send&& send
|
||||
)
|
||||
{
|
||||
namespace urls = boost::urls;
|
||||
|
||||
const std::string& route = req.target();
|
||||
const bool is_match_route = routes_pathes_.count(route);
|
||||
|
||||
@@ -178,21 +183,25 @@ public:
|
||||
}
|
||||
catch (const session_exception& e)
|
||||
{
|
||||
boost::beast::http::response<ResponseType> res{e.code, req.version()};
|
||||
boost::json::value response_body;
|
||||
|
||||
response_body.emplace_object();
|
||||
response_body.as_object().emplace("Result", e.what());
|
||||
|
||||
res.body() = serialize(response_body);
|
||||
res.set(boost::beast::http::field::content_type, "application/json");
|
||||
res.content_length(res.body().size());
|
||||
|
||||
return send(std::move(res));
|
||||
return send(SendSessionExceptionError(std::move(req), e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// urls::url_view parsed_view = urls::parse_uri_reference("/api/v1/Diaries/123").value();
|
||||
// auto segs = parsed_view.segments();
|
||||
// std::vector<std::string_view> parts;
|
||||
//
|
||||
// for (auto s : segs)
|
||||
// parts.push_back(s);
|
||||
//
|
||||
// if (parts.size() == 4 &&
|
||||
// parts[0] == "api" &&
|
||||
// parts[2] == "Diaries")
|
||||
// {
|
||||
// std::string uuid = std::string(parts[3]);
|
||||
// }
|
||||
|
||||
if (req.method() != boost::beast::http::verb::get &&
|
||||
req.method() != boost::beast::http::verb::head)
|
||||
return send(SendBadRequest(std::move(req), "Unknown boost::beast::HTTP-method"));
|
||||
@@ -289,5 +298,20 @@ private:
|
||||
res.prepare_payload();
|
||||
return res;
|
||||
}
|
||||
|
||||
boost::beast::http::response<ResponseType> SendSessionExceptionError(Request&& req, const session_exception& e)
|
||||
{
|
||||
boost::beast::http::response<ResponseType> res{e.code, req.version()};
|
||||
boost::json::value response_body;
|
||||
|
||||
response_body.emplace_object();
|
||||
response_body.as_object().emplace("Result", e.what());
|
||||
|
||||
res.body() = serialize(response_body);
|
||||
res.set(boost::beast::http::field::content_type, "application/json");
|
||||
res.content_length(res.body().size());
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user