diff options
author | Ed Tanous <edtanous@google.com> | 2023-04-25 01:28:50 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2023-05-16 19:05:33 +0300 |
commit | ef4c65b741724d724452a3a0efe8dff0d450514a (patch) | |
tree | 9667bdff1dd9d2dbeac94bc8bd46efd83177512b /redfish-core/lib/metric_report.hpp | |
parent | a87c4180fd7f2127960fbc4c89c31b7659f0cfb8 (diff) | |
download | bmcweb-ef4c65b741724d724452a3a0efe8dff0d450514a.tar.xz |
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
Diffstat (limited to 'redfish-core/lib/metric_report.hpp')
-rw-r--r-- | redfish-core/lib/metric_report.hpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/redfish-core/lib/metric_report.hpp b/redfish-core/lib/metric_report.hpp index 7ae80d7265..1f21c91fed 100644 --- a/redfish-core/lib/metric_report.hpp +++ b/redfish-core/lib/metric_report.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 <array> @@ -45,12 +46,12 @@ inline bool fillReport(nlohmann::json& json, const std::string& id, const TimestampReadings& timestampReadings) { json["@odata.type"] = "#MetricReport.v1_3_0.MetricReport"; - json["@odata.id"] = crow::utility::urlFromPieces( - "redfish", "v1", "TelemetryService", "MetricReports", id); + json["@odata.id"] = boost::urls::format( + "/redfish/v1/TelemetryService/MetricReports/{}", id); json["Id"] = id; json["Name"] = id; - json["MetricReportDefinition"]["@odata.id"] = crow::utility::urlFromPieces( - "redfish", "v1", "TelemetryService", "MetricReportDefinitions", id); + json["MetricReportDefinition"]["@odata.id"] = boost::urls::format( + "/redfish/v1/TelemetryService/MetricReportDefinitions/{}", id); const auto& [timestamp, readings] = timestampReadings; json["Timestamp"] = redfish::time_utils::getDateTimeUintMs(timestamp); |