diff options
author | zhanghch05 <zhanghch05@inspur.com> | 2021-04-01 06:18:24 +0300 |
---|---|---|
committer | zhanghch05 <zhanghch05@inspur.com> | 2021-04-08 04:01:21 +0300 |
commit | 8d1b46d7f8d39db2ba048f9e9007106ca3a28c9b (patch) | |
tree | 821fcb9b383fdf3db22db77e154cd7f57606d402 /redfish-core/lib/message_registries.hpp | |
parent | dab0604af234bdd5010407031a01343d6c242edf (diff) | |
download | bmcweb-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/message_registries.hpp')
-rw-r--r-- | redfish-core/lib/message_registries.hpp | 61 |
1 files changed, 27 insertions, 34 deletions
diff --git a/redfish-core/lib/message_registries.hpp b/redfish-core/lib/message_registries.hpp index 77fc10eba9..455bf70570 100644 --- a/redfish-core/lib/message_registries.hpp +++ b/redfish-core/lib/message_registries.hpp @@ -44,13 +44,13 @@ class MessageRegistryFileCollection : public Node /** * Functions triggers appropriate requests on DBus */ - 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 { // Collections don't include the static data added by SubRoute because // it has a duplicate entry for members - res.jsonValue = { + asyncResp->res.jsonValue = { {"@odata.type", "#MessageRegistryFileCollection.MessageRegistryFileCollection"}, {"@odata.id", "/redfish/v1/Registries"}, @@ -62,8 +62,6 @@ class MessageRegistryFileCollection : public Node {{"@odata.id", "/redfish/v1/Registries/TaskEvent"}}, {{"@odata.id", "/redfish/v1/Registries/ResourceEvent"}}, {{"@odata.id", "/redfish/v1/Registries/OpenBMC"}}}}}; - - res.end(); } }; @@ -83,13 +81,13 @@ class MessageRegistryFile : 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 { if (params.size() != 1) { - messages::internalError(res); - res.end(); + messages::internalError(asyncResp->res); return; } @@ -121,13 +119,12 @@ class MessageRegistryFile : public Node else { messages::resourceNotFound( - res, "#MessageRegistryFile.v1_1_0.MessageRegistryFile", - registry); - res.end(); + asyncResp->res, + "#MessageRegistryFile.v1_1_0.MessageRegistryFile", registry); return; } - res.jsonValue = { + asyncResp->res.jsonValue = { {"@odata.id", "/redfish/v1/Registries/" + registry}, {"@odata.type", "#MessageRegistryFile.v1_1_0.MessageRegistryFile"}, {"Name", registry + " Message Registry File"}, @@ -145,10 +142,8 @@ class MessageRegistryFile : public Node if (url != nullptr) { - res.jsonValue["Location"][0]["PublicationUri"] = url; + asyncResp->res.jsonValue["Location"][0]["PublicationUri"] = url; } - - res.end(); } }; @@ -169,13 +164,13 @@ class MessageRegistry : 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 { if (params.size() != 2) { - messages::internalError(res); - res.end(); + messages::internalError(asyncResp->res); return; } @@ -223,30 +218,29 @@ class MessageRegistry : public Node else { messages::resourceNotFound( - res, "#MessageRegistryFile.v1_1_0.MessageRegistryFile", - registry); - res.end(); + asyncResp->res, + "#MessageRegistryFile.v1_1_0.MessageRegistryFile", registry); return; } if (registry != registry1) { - messages::resourceNotFound(res, header->type, registry1); - res.end(); + messages::resourceNotFound(asyncResp->res, header->type, registry1); return; } - res.jsonValue = {{"@Redfish.Copyright", header->copyright}, - {"@odata.type", header->type}, - {"Id", header->id}, - {"Name", header->name}, - {"Language", header->language}, - {"Description", header->description}, - {"RegistryPrefix", header->registryPrefix}, - {"RegistryVersion", header->registryVersion}, - {"OwningEntity", header->owningEntity}}; + asyncResp->res.jsonValue = { + {"@Redfish.Copyright", header->copyright}, + {"@odata.type", header->type}, + {"Id", header->id}, + {"Name", header->name}, + {"Language", header->language}, + {"Description", header->description}, + {"RegistryPrefix", header->registryPrefix}, + {"RegistryVersion", header->registryVersion}, + {"OwningEntity", header->owningEntity}}; - nlohmann::json& messageObj = res.jsonValue["Messages"]; + nlohmann::json& messageObj = asyncResp->res.jsonValue["Messages"]; // Go through the Message Registry and populate each Message for (const message_registries::MessageEntry* message : registryEntries) @@ -271,7 +265,6 @@ class MessageRegistry : public Node } } } - res.end(); } }; |