Разработка ручки для GetAllMedications

This commit is contained in:
2026-01-07 10:48:13 +03:00
parent 28a2f526bf
commit f06d22febf
2 changed files with 18 additions and 1 deletions
+1 -1
View File
@@ -80,7 +80,7 @@ public:
} }
); );
routes_pathes_["api/v1/User/Medications"] = std::make_unique<RouteController>( routes_pathes_["/api/v1/User/Medications"] = std::make_unique<RouteController>(
typename RouteController::HTTPMethodsToExecutors{ typename RouteController::HTTPMethodsToExecutors{
{ {
boost::beast::http::verb::get, boost::beast::http::verb::get,
@@ -36,6 +36,23 @@ public:
using namespace boost::json; using namespace boost::json;
using namespace boost::beast; using namespace boost::beast;
using namespace std::string_literals; using namespace std::string_literals;
using namespace std::string_view_literals;
constexpr std::string_view auth_prefix = "Bearer "sv;
BOOST_LOG_TRIVIAL(info) << "GET /api/v1/User/Medications - Request";
if (req[http::field::authorization].begin() == req[http::field::authorization].end())
{
BOOST_LOG_TRIVIAL(info) << "GET /api/v1/User/Medications - Response 401: Unauthorized";
throw session_exception(http::status::unauthorized, "Unauthorized");
}
const std::string auth_string = {*req[http::field::authorization].begin()};
const std::string auth_token = {auth_string.begin() + auth_prefix.size(), auth_string.end()};
if (auth_dao_->HasAuthorized(auth_token)) {}
http::response<ResponseType> res{http::status::ok, req.version()}; http::response<ResponseType> res{http::status::ok, req.version()};