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/power_subsystem.hpp b/redfish-core/lib/power_subsystem.hpp
index 52e1ec9..d54fd18 100644
--- a/redfish-core/lib/power_subsystem.hpp
+++ b/redfish-core/lib/power_subsystem.hpp
@@ -6,6 +6,8 @@
#include "registries/privilege_registry.hpp"
#include "utils/chassis_utils.hpp"
+#include <boost/url/format.hpp>
+
#include <memory>
#include <optional>
#include <string>
@@ -31,13 +33,13 @@
"#PowerSubsystem.v1_1_0.PowerSubsystem";
asyncResp->res.jsonValue["Name"] = "Power Subsystem";
asyncResp->res.jsonValue["Id"] = "PowerSubsystem";
- asyncResp->res.jsonValue["@odata.id"] = crow::utility::urlFromPieces(
- "redfish", "v1", "Chassis", chassisId, "PowerSubsystem");
+ asyncResp->res.jsonValue["@odata.id"] =
+ boost::urls::format("/redfish/v1/Chassis/{}/PowerSubsystem", chassisId);
asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
asyncResp->res.jsonValue["Status"]["Health"] = "OK";
asyncResp->res.jsonValue["PowerSupplies"]["@odata.id"] =
- crow::utility::urlFromPieces("redfish", "v1", "Chassis", chassisId,
- "PowerSubsystem", "PowerSupplies");
+ boost::urls::format(
+ "/redfish/v1/Chassis/{}/PowerSubsystem/PowerSupplies", chassisId);
}
inline void handlePowerSubsystemCollectionHead(