Avoid http request copy in OEM handler
Initial copy was done to avoid request object going out of scope before
OEM handler are invoked.
The MR avoids the whole copy of the request object and create a sub
route object which contains elements required for OEM route handling.
Tested
- Service Validator Passes
- OpenBMC OEM properties and rendered well.
Change-Id: I3ef80a130afe6ab764a13704a8b672f5b0635126
Signed-off-by: Rohit PAI <ropai@nvidia.com>
diff --git a/redfish-core/include/redfishoemrule.hpp b/redfish-core/include/redfishoemrule.hpp
index 018a18e..d3f60fb 100644
--- a/redfish-core/include/redfishoemrule.hpp
+++ b/redfish-core/include/redfishoemrule.hpp
@@ -1,6 +1,6 @@
#pragma once
#include "async_resp.hpp"
-#include "http_request.hpp"
+#include "sub_request.hpp"
#include <nlohmann/json.hpp>
@@ -24,9 +24,9 @@
OemBaseRule& operator=(const OemBaseRule&) = delete;
OemBaseRule& operator=(const OemBaseRule&&) = delete;
- virtual void handle(const crow::Request& /*req*/,
+ virtual void handle(const SubRequest& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::vector<std::string>& /*params*/) = 0;
+ const std::vector<std::string>& params) = 0;
std::string rule;
};
@@ -51,12 +51,12 @@
void operator()(Func&& f)
{
static_assert(
- std::is_invocable_v<Func, crow::Request,
+ std::is_invocable_v<Func, SubRequest,
std::shared_ptr<bmcweb::AsyncResp>&, Args...>,
"Handler type is mismatched with URL parameters");
static_assert(
std::is_same_v<
- void, std::invoke_result_t<Func, crow::Request,
+ void, std::invoke_result_t<Func, SubRequest,
std::shared_ptr<bmcweb::AsyncResp>&,
Args...>>,
"Handler function with response argument should have void return type");
@@ -64,7 +64,7 @@
handler = std::forward<Func>(f);
}
- void handle(const crow::Request& req,
+ void handle(const SubRequest& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::vector<std::string>& params) override
{
@@ -97,7 +97,7 @@
}
private:
- std::function<void(const crow::Request&,
+ std::function<void(const SubRequest&,
const std::shared_ptr<bmcweb::AsyncResp>&, Args...)>
handler;
};