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/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 0ea53e2..93c475e 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -28,6 +28,7 @@
 #include <boost/algorithm/string/classification.hpp>
 #include <boost/algorithm/string/split.hpp>
 #include <boost/container/flat_set.hpp>
+#include <boost/url/format.hpp>
 
 #include <array>
 #include <optional>
@@ -1576,8 +1577,8 @@
 
     nlohmann::json& jsonResponse = asyncResp->res.jsonValue;
     jsonResponse["Id"] = ifaceId;
-    jsonResponse["@odata.id"] = crow::utility::urlFromPieces(
-        "redfish", "v1", "Managers", "bmc", "EthernetInterfaces", ifaceId);
+    jsonResponse["@odata.id"] = boost::urls::format(
+        "/redfish/v1/Managers/bmc/EthernetInterfaces/{}", ifaceId);
     jsonResponse["InterfaceEnabled"] = ethData.nicEnabled;
 
     auto health = std::make_shared<HealthPopulate>(asyncResp);
@@ -1638,9 +1639,8 @@
         jsonResponse["FQDN"] = fqdn;
     }
 
-    jsonResponse["VLANs"]["@odata.id"] =
-        crow::utility::urlFromPieces("redfish", "v1", "Managers", "bmc",
-                                     "EthernetInterfaces", ifaceId, "VLANs");
+    jsonResponse["VLANs"]["@odata.id"] = boost::urls::format(
+        "/redfish/v1/Managers/bmc/EthernetInterfaces/{}/VLANs", ifaceId);
 
     jsonResponse["NameServers"] = ethData.nameServers;
     jsonResponse["StaticNameServers"] = ethData.staticNameServers;
@@ -1750,9 +1750,9 @@
                 if (found == std::string::npos)
                 {
                     nlohmann::json::object_t iface;
-                    iface["@odata.id"] = crow::utility::urlFromPieces(
-                        "redfish", "v1", "Managers", "bmc",
-                        "EthernetInterfaces", ifaceItem);
+                    iface["@odata.id"] = boost::urls::format(
+                        "/redfish/v1/Managers/bmc/EthernetInterfaces/{}",
+                        ifaceItem);
                     ifaceArray.emplace_back(std::move(iface));
                 }
             }
@@ -1983,10 +1983,9 @@
             if (success && ethData.vlanId)
             {
                 asyncResp->res.jsonValue["Id"] = ifaceId;
-                asyncResp->res.jsonValue["@odata.id"] =
-                    crow::utility::urlFromPieces(
-                        "redfish", "v1", "Managers", "bmc",
-                        "EthernetInterfaces", parentIfaceId, "VLANs", ifaceId);
+                asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
+                    "/redfish/v1/Managers/bmc/EthernetInterfaces/{}/VLANs/{}",
+                    parentIfaceId, ifaceId);
 
                 asyncResp->res.jsonValue["VLANEnable"] = ethData.nicEnabled;
                 asyncResp->res.jsonValue["VLANId"] = *ethData.vlanId;
@@ -2172,20 +2171,18 @@
                 if (ifaceItem.starts_with(rootInterfaceName + "_"))
                 {
                     nlohmann::json::object_t iface;
-                    iface["@odata.id"] = crow::utility::urlFromPieces(
-                        "redfish", "v1", "Managers", "bmc",
-                        "EthernetInterfaces", rootInterfaceName, "VLANs",
-                        ifaceItem);
+                    iface["@odata.id"] = boost::urls::format(
+                        "/redfish/v1/Managers/bmc/EthernetInterfaces/{}/VLANs/{}",
+                        rootInterfaceName, ifaceItem);
                     ifaceArray.emplace_back(std::move(iface));
                 }
             }
 
             asyncResp->res.jsonValue["Members@odata.count"] = ifaceArray.size();
             asyncResp->res.jsonValue["Members"] = std::move(ifaceArray);
-            asyncResp->res.jsonValue["@odata.id"] =
-                crow::utility::urlFromPieces("redfish", "v1", "Managers", "bmc",
-                                             "EthernetInterfaces",
-                                             rootInterfaceName, "VLANs");
+            asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
+                "/redfish/v1/Managers/bmc/EthernetInterfaces/{}/VLANs",
+                rootInterfaceName);
         });
         });