Revert "Change the completionhandler to accept Res"

This reverts commit 91995f3272010875e1559397e98ca93354066a0e.

Seeing bumps fail.
https://gerrit.openbmc-project.xyz/c/openbmc/openbmc/+/48864

Please fix, test, and resubmit.

Change-Id: Id539fe66d5a093caf8f22a393f7af7b58ead5247
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/include/async_resp.hpp b/include/async_resp.hpp
index 7306017..8e9584c 100644
--- a/include/async_resp.hpp
+++ b/include/async_resp.hpp
@@ -15,17 +15,28 @@
 class AsyncResp
 {
   public:
-    AsyncResp() = default;
+    AsyncResp(crow::Response& response) : res(response)
+    {}
+
+    AsyncResp(crow::Response& response, std::function<void()>&& function) :
+        res(response), func(std::move(function))
+    {}
 
     AsyncResp(const AsyncResp&) = delete;
     AsyncResp(AsyncResp&&) = delete;
 
     ~AsyncResp()
     {
+        if (func && res.result() == boost::beast::http::status::ok)
+        {
+            func();
+        }
+
         res.end();
     }
 
-    crow::Response res;
+    crow::Response& res;
+    std::function<void()> func;
 };
 
 } // namespace bmcweb
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index 0096e86..3188188 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -2233,7 +2233,9 @@
             [](const crow::Request&,
                const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
                const std::string& connection) {
-                introspectObjects(connection, "/", asyncResp);
+                introspectObjects(
+                    connection, "/",
+                    std::make_shared<bmcweb::AsyncResp>(asyncResp->res));
             });
 
     BMCWEB_ROUTE(app, "/bus/system/<str>/<path>")