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/trigger.hpp b/redfish-core/lib/trigger.hpp
index 5fe9678..68d6dd2 100644
--- a/redfish-core/lib/trigger.hpp
+++ b/redfish-core/lib/trigger.hpp
@@ -8,6 +8,7 @@
#include "utils/telemetry_utils.hpp"
#include "utils/time_utils.hpp"
+#include <boost/url/format.hpp>
#include <sdbusplus/asio/property.hpp>
#include <sdbusplus/unpack_properties.hpp>
@@ -161,9 +162,9 @@
}
nlohmann::json::object_t report;
- report["@odata.id"] =
- crow::utility::urlFromPieces("redfish", "v1", "TelemetryService",
- "MetricReportDefinitions", reportId);
+ report["@odata.id"] = boost::urls::format(
+ "/redfish/v1/TelemetryService/MetricReportDefinitions/{}",
+ reportId);
reports.emplace_back(std::move(report));
}
@@ -282,8 +283,8 @@
}
json["@odata.type"] = "#Triggers.v1_2_0.Triggers";
- json["@odata.id"] = crow::utility::urlFromPieces(
- "redfish", "v1", "TelemetryService", "Triggers", id);
+ json["@odata.id"] =
+ boost::urls::format("/redfish/v1/TelemetryService/Triggers/{}", id);
json["Id"] = id;
return true;