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