summaryrefslogtreecommitdiff
path: root/redfish-core/lib/task.hpp
diff options
context:
space:
mode:
authorzhanghch05 <zhanghch05@inspur.com>2021-04-01 06:18:24 +0300
committerzhanghch05 <zhanghch05@inspur.com>2021-04-08 04:01:21 +0300
commit8d1b46d7f8d39db2ba048f9e9007106ca3a28c9b (patch)
tree821fcb9b383fdf3db22db77e154cd7f57606d402 /redfish-core/lib/task.hpp
parentdab0604af234bdd5010407031a01343d6c242edf (diff)
downloadbmcweb-8d1b46d7f8d39db2ba048f9e9007106ca3a28c9b.tar.xz
Using AsyncResp everywhere
Get the core using AsyncResp everywhere, and not have each individual handler creating its own object.We can call app.handle() without fear of the response getting ended after the first tree is done populating. Don't use res.end() anymore. Tested: 1. Validator passed. Signed-off-by: zhanghaicheng <zhanghch05@inspur.com> Change-Id: I867367ce4a0caf8c4b3f4e07e06c11feed0782e8
Diffstat (limited to 'redfish-core/lib/task.hpp')
-rw-r--r--redfish-core/lib/task.hpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/redfish-core/lib/task.hpp b/redfish-core/lib/task.hpp
index dbc6278897..275806f0eb 100644
--- a/redfish-core/lib/task.hpp
+++ b/redfish-core/lib/task.hpp
@@ -331,10 +331,11 @@ class TaskMonitor : public Node
}
private:
- void doGet(crow::Response& res, const crow::Request&,
+ void doGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const crow::Request&,
const std::vector<std::string>& params) override
{
- auto asyncResp = std::make_shared<AsyncResp>(res);
+
if (params.size() != 1)
{
messages::internalError(asyncResp->res);
@@ -387,10 +388,11 @@ class Task : public Node
}
private:
- void doGet(crow::Response& res, const crow::Request&,
+ void doGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const crow::Request&,
const std::vector<std::string>& params) override
{
- auto asyncResp = std::make_shared<AsyncResp>(res);
+
if (params.size() != 1)
{
messages::internalError(asyncResp->res);
@@ -469,10 +471,10 @@ class TaskCollection : public Node
}
private:
- void doGet(crow::Response& res, const crow::Request&,
- const std::vector<std::string>&) override
+ void doGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const crow::Request&, const std::vector<std::string>&) override
{
- auto asyncResp = std::make_shared<AsyncResp>(res);
+
asyncResp->res.jsonValue["@odata.type"] =
"#TaskCollection.TaskCollection";
asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/TaskService/Tasks";
@@ -509,10 +511,9 @@ class TaskService : public Node
}
private:
- void doGet(crow::Response& res, const crow::Request&,
- const std::vector<std::string>&) override
+ void doGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const crow::Request&, const std::vector<std::string>&) override
{
- auto asyncResp = std::make_shared<AsyncResp>(res);
asyncResp->res.jsonValue["@odata.type"] =
"#TaskService.v1_1_4.TaskService";
asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/TaskService";