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/fabric_adapters.hpp b/redfish-core/lib/fabric_adapters.hpp
index be89fbc..16174bf 100644
--- a/redfish-core/lib/fabric_adapters.hpp
+++ b/redfish-core/lib/fabric_adapters.hpp
@@ -9,6 +9,7 @@
#include "utils/json_utils.hpp"
#include <boost/system/error_code.hpp>
+#include <boost/url/format.hpp>
#include <sdbusplus/asio/property.hpp>
#include <sdbusplus/unpack_properties.hpp>
@@ -184,8 +185,8 @@
aResp->res.jsonValue["@odata.type"] = "#FabricAdapter.v1_4_0.FabricAdapter";
aResp->res.jsonValue["Name"] = "Fabric Adapter";
aResp->res.jsonValue["Id"] = adapterId;
- aResp->res.jsonValue["@odata.id"] = crow::utility::urlFromPieces(
- "redfish", "v1", "Systems", systemName, "FabricAdapters", adapterId);
+ aResp->res.jsonValue["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Systems/{}/FabricAdapters/{}", systemName, adapterId);
aResp->res.jsonValue["Status"]["State"] = "Enabled";
aResp->res.jsonValue["Status"]["Health"] = "OK";
@@ -283,8 +284,8 @@
aResp->res.jsonValue["@odata.type"] =
"#FabricAdapterCollection.FabricAdapterCollection";
aResp->res.jsonValue["Name"] = "Fabric Adapter Collection";
- aResp->res.jsonValue["@odata.id"] = crow::utility::urlFromPieces(
- "redfish", "v1", "Systems", systemName, "FabricAdapters");
+ aResp->res.jsonValue["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Systems/{}/FabricAdapters", systemName);
constexpr std::array<std::string_view, 1> interfaces{
"xyz.openbmc_project.Inventory.Item.FabricAdapter"};