{std::string("/v1/" #api_name "/" #call_name), \
[
this](
string,
string body, url_response_callback cb)
mutable { \
if (body.empty()) body = "{}"; \
/*plugin processes many transactions, report only first to avoid http_plugin having to deal with multiple responses*/ \
auto times_called = std::make_shared<std::atomic<size_t>>(0);\
auto result_handler = [times_called{std::move(times_called)}, cb, body](const fc::exception_ptr& e) mutable {\
if( ++(*times_called) > 1 ) return;\
if (e) {\
try {\
e->dynamic_rethrow_exception();\
} catch (...) {\
http_plugin::handle_exception(#api_name, #call_name, body, cb);\
}\
} else {\
cb(http_response_code, fc::variant(sysio::detail::txn_test_gen_empty())); \
}\
};\
INVOKE \
}\
}
68#define CALL_ASYNC(api_name, api_handle, call_name, INVOKE, http_response_code) \
69{std::string("/v1/" #api_name "/" #call_name), \
70 [this](string, string body, url_response_callback cb) mutable { \
71 if (body.empty()) body = "{}"; \
72 \
73 auto times_called = std::make_shared<std::atomic<size_t>>(0);\
74 auto result_handler = [times_called{std::move(times_called)}, cb, body](const fc::exception_ptr& e) mutable {\
75 if( ++(*times_called) > 1 ) return;\
76 if (e) {\
77 try {\
78 e->dynamic_rethrow_exception();\
79 } catch (...) {\
80 http_plugin::handle_exception(#api_name, #call_name, body, cb);\
81 }\
82 } else {\
83 cb(http_response_code, fc::variant(sysio::detail::txn_test_gen_empty())); \
84 }\
85 };\
86 INVOKE \
87 }\
88}