Boost::urls::format
Boost 1.82 dropped a lovely new toy, boost::urls::format, which is a lot
like our urlFromPieces method, but better in that it makes the resulting
uris more readable, and allows doing things like fragments in a single
line instead of multiple. We should prefer it in some cases.
Tested:
Redfish service validator passes.
Spot checks of URLs work as expected.
Unit tests pass.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ia7b38f0a95771c862507e7d5b4aa68aa1c98403c
diff --git a/redfish-core/lib/message_registries.hpp b/redfish-core/lib/message_registries.hpp
index ce147a8..ead4e38 100644
--- a/redfish-core/lib/message_registries.hpp
+++ b/redfish-core/lib/message_registries.hpp
@@ -24,6 +24,8 @@
#include "registries/resource_event_message_registry.hpp"
#include "registries/task_event_message_registry.hpp"
+#include <boost/url/format.hpp>
+
#include <array>
namespace redfish
@@ -53,8 +55,8 @@
std::to_array({"Base", "TaskEvent", "ResourceEvent", "OpenBMC"}))
{
nlohmann::json::object_t member;
- member["@odata.id"] = crow::utility::urlFromPieces(
- "redfish", "v1", "Registries", memberName);
+ member["@odata.id"] = boost::urls::format("/redfish/v1/Registries/{}",
+ memberName);
members.emplace_back(std::move(member));
}
}
@@ -111,7 +113,7 @@
}
asyncResp->res.jsonValue["@odata.id"] =
- crow::utility::urlFromPieces("redfish", "v1", "Registries", registry);
+ boost::urls::format("/redfish/v1/Registries/{}", registry);
asyncResp->res.jsonValue["@odata.type"] =
"#MessageRegistryFile.v1_1_0.MessageRegistryFile";
asyncResp->res.jsonValue["Name"] = registry + " Message Registry File";