summaryrefslogtreecommitdiff
path: root/redfish-core/include/utils
diff options
context:
space:
mode:
authorWilly Tu <wltu@google.com>2022-09-27 08:48:07 +0300
committerEd Tanous <ed@tanous.net>2022-11-02 20:00:26 +0300
commitae9031f0e8595ee88945ac565d10be0c3832ed01 (patch)
tree7cf1c6aa5e91aa80cac6441b5955edb9a355dd54 /redfish-core/include/utils
parent6107da1e94ce2e3b5ea975f13e7410583ecb815f (diff)
downloadbmcweb-ae9031f0e8595ee88945ac565d10be0c3832ed01.tar.xz
Update CollectionMembers to use UrlFromPieces
Refactor getCollectionMembers to make sure all Url created with dbus paths are generated via UrlFromPieces helper function. This allow us to manage all URL generated from dbus in one place and allow us to make future changes to affect all resources. We can make changes to all resources easier if they are all managed by one function. Tested: Redfish Validator Passed. All Collections working as expected and match previous implmentation. Change-Id: I5d3b2b32f047ce4f20a2287a36a3e099efd6eace Signed-off-by: Willy Tu <wltu@google.com>
Diffstat (limited to 'redfish-core/include/utils')
-rw-r--r--redfish-core/include/utils/collection.hpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/redfish-core/include/utils/collection.hpp b/redfish-core/include/utils/collection.hpp
index 7a845d1e38..97f622d8f4 100644
--- a/redfish-core/include/utils/collection.hpp
+++ b/redfish-core/include/utils/collection.hpp
@@ -24,11 +24,12 @@ namespace collection_util
*/
inline void
getCollectionMembers(std::shared_ptr<bmcweb::AsyncResp> aResp,
- const std::string& collectionPath,
+ const boost::urls::url& collectionPath,
const std::vector<const char*>& interfaces,
const char* subtree = "/xyz/openbmc_project/inventory")
{
- BMCWEB_LOG_DEBUG << "Get collection members for: " << collectionPath;
+ BMCWEB_LOG_DEBUG << "Get collection members for: "
+ << collectionPath.string();
crow::connections::systemBus->async_method_call(
[collectionPath, aResp{std::move(aResp)}](
const boost::system::error_code ec,
@@ -65,11 +66,10 @@ inline void
members = nlohmann::json::array();
for (const std::string& leaf : pathNames)
{
- std::string newPath = collectionPath;
- newPath += '/';
- newPath += leaf;
+ boost::urls::url url = collectionPath;
+ crow::utility::appendUrlPieces(url, leaf);
nlohmann::json::object_t member;
- member["@odata.id"] = std::move(newPath);
+ member["@odata.id"] = std::move(url);
members.push_back(std::move(member));
}
aResp->res.jsonValue["Members@odata.count"] = members.size();