Boost beast
This commit is the beginings of attempting to transition away from
crow, and toward boost::beast. Unit tests are passing, and
implementation appears to be slightly faster than crow.
Change-Id: Ic8d946dc7a04f514c67b1098f181eee1ced69171
diff --git a/redfish-core/include/node.hpp b/redfish-core/include/node.hpp
index b41439a..3fb0ce7 100644
--- a/redfish-core/include/node.hpp
+++ b/redfish-core/include/node.hpp
@@ -102,19 +102,19 @@
virtual void doPatch(crow::response& res, const crow::request& req,
const std::vector<std::string>& params) {
- res.code = static_cast<int>(HttpRespCode::METHOD_NOT_ALLOWED);
+ res.result(boost::beast::http::status::method_not_allowed);
res.end();
}
virtual void doPost(crow::response& res, const crow::request& req,
const std::vector<std::string>& params) {
- res.code = static_cast<int>(HttpRespCode::METHOD_NOT_ALLOWED);
+ res.result(boost::beast::http::status::method_not_allowed);
res.end();
}
virtual void doDelete(crow::response& res, const crow::request& req,
const std::vector<std::string>& params) {
- res.code = static_cast<int>(HttpRespCode::METHOD_NOT_ALLOWED);
+ res.result(boost::beast::http::status::method_not_allowed);
res.end();
}
@@ -127,14 +127,14 @@
auto ctx =
app.template get_context<crow::TokenAuthorization::Middleware>(req);
- if (!isMethodAllowedForUser(req.method, entityPrivileges,
+ if (!isMethodAllowedForUser(req.method(), entityPrivileges,
ctx.session->username)) {
- res.code = static_cast<int>(HttpRespCode::METHOD_NOT_ALLOWED);
+ res.result(boost::beast::http::status::method_not_allowed);
res.end();
return;
}
- switch (req.method) {
+ switch (req.method()) {
case "GET"_method:
doGet(res, req, params);
break;
@@ -152,7 +152,7 @@
break;
default:
- res.code = static_cast<int>(HttpRespCode::NOT_FOUND);
+ res.result(boost::beast::http::status::not_found);
res.end();
}
return;