bmcweb:Properly implement the / operator in dbus

Per the documentation here:
https://github.com/openbmc/docs/blob/master/rest-api.md

It states:
"When a path has a trailing-slash, the response will list the sub
objects of the URL. For example, using the same object path as above,
but adding a slash"

This subtlety was missed by the original author of this stuff, and as
such, didn't work the way the old APIs were expecting.

Tested By:
HTTP GET /xyz/openbmc_project/
Before this patchset, returns an empty object
{
    "data": [],
    "message": "200 OK",
    "status": "ok"
}

After this patchset, returns:
{
    "data": [
        "/xyz/openbmc_project/EntityManager",
        "/xyz/openbmc_project/FruDevice",
        "/xyz/openbmc_project/bios",
        "/xyz/openbmc_project/control",
        "/xyz/openbmc_project/dump",
        "/xyz/openbmc_project/events",
        "/xyz/openbmc_project/inventory",
        "/xyz/openbmc_project/logging",
        "/xyz/openbmc_project/network",
        "/xyz/openbmc_project/object_mapper",
        "/xyz/openbmc_project/software",
        "/xyz/openbmc_project/user"
    ],
    "message": "200 OK",
    "status": "ok"
}

Note, to get the exact same responses (which don't include the root
object) this patchset is required:
https://gerrit.openbmc-project.xyz/#/c/openbmc/phosphor-objmgr/+/15545/

Change-Id: I79b192bc26879cdfa25977f403940d3608eb3e22
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index 6cdc24b..c242539 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -735,7 +735,8 @@
         std::array<std::string, 0>());
 }
 
-void handleList(crow::Response &res, const std::string &objectPath)
+void handleList(crow::Response &res, const std::string &objectPath,
+                int32_t depth = 0)
 {
     crow::connections::systemBus->async_method_call(
         [&res](const boost::system::error_code ec,
@@ -755,7 +756,7 @@
         "xyz.openbmc_project.ObjectMapper",
         "/xyz/openbmc_project/object_mapper",
         "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", objectPath,
-        static_cast<int32_t>(0), std::array<std::string, 0>());
+        depth, std::array<std::string, 0>());
 }
 
 void handleEnumerate(crow::Response &res, const std::string &objectPath)
@@ -1132,11 +1133,6 @@
 inline void handleDBusUrl(const crow::Request &req, crow::Response &res,
                           std::string &objectPath)
 {
-    // Trim any trailing "/" at the end
-    if (boost::ends_with(objectPath, "/"))
-    {
-        objectPath.pop_back();
-    }
 
     // If accessing a single attribute, fill in and update objectPath,
     // otherwise leave destProperty blank
@@ -1180,7 +1176,16 @@
         }
         else
         {
-            handleGet(res, objectPath, destProperty);
+            // Trim any trailing "/" at the end
+            if (boost::ends_with(objectPath, "/"))
+            {
+                objectPath.pop_back();
+                handleList(res, objectPath, 1);
+            }
+            else
+            {
+                handleGet(res, objectPath, destProperty);
+            }
         }
         return;
     }