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/task.hpp b/redfish-core/lib/task.hpp
index 167a0c7..e0058f5 100644
--- a/redfish-core/lib/task.hpp
+++ b/redfish-core/lib/task.hpp
@@ -26,6 +26,7 @@
#include <boost/asio/post.hpp>
#include <boost/asio/steady_timer.hpp>
+#include <boost/url/format.hpp>
#include <sdbusplus/bus/match.hpp>
#include <chrono>
@@ -409,8 +410,8 @@
}
asyncResp->res.jsonValue["TaskStatus"] = ptr->status;
asyncResp->res.jsonValue["Messages"] = ptr->messages;
- asyncResp->res.jsonValue["@odata.id"] = crow::utility::urlFromPieces(
- "redfish", "v1", "TaskService", "Tasks", strParam);
+ asyncResp->res.jsonValue["@odata.id"] =
+ boost::urls::format("/redfish/v1/TaskService/Tasks/{}", strParam);
if (!ptr->gave204)
{
asyncResp->res.jsonValue["TaskMonitor"] =
@@ -456,9 +457,9 @@
continue; // shouldn't be possible
}
nlohmann::json::object_t member;
- member["@odata.id"] = crow::utility::urlFromPieces(
- "redfish", "v1", "TaskService", "Tasks",
- std::to_string(task->index));
+ member["@odata.id"] =
+ boost::urls::format("/redfish/v1/TaskService/Tasks/{}",
+ std::to_string(task->index));
members.emplace_back(std::move(member));
}
});