diff options
Diffstat (limited to 'include/async_resp.hpp')
| -rw-r--r-- | include/async_resp.hpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/include/async_resp.hpp b/include/async_resp.hpp index af4edeb..78994cf 100644 --- a/include/async_resp.hpp +++ b/include/async_resp.hpp @@ -1,5 +1,7 @@ #pragma once +#include <functional> + namespace bmcweb { @@ -7,6 +9,7 @@ namespace bmcweb * AsyncResp * Gathers data needed for response processing after async calls are done */ + class AsyncResp { public: @@ -14,12 +17,23 @@ class AsyncResp { } + AsyncResp(crow::Response& response, std::function<void()>&& function) : + res(response), func(std::move(function)) + { + } + ~AsyncResp() { + if (func && res.result() == boost::beast::http::status::ok) + { + func(); + } + res.end(); } crow::Response& res; + std::function<void()> func = 0; }; -} // namespace bmcweb
\ No newline at end of file +} // namespace bmcweb |

