Skip to content

Commit 143fd72

Browse files
committed
Fix route_params::spawn to use capy::executor::post
1 parent 622d39b commit 143fd72

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

src/server/route_handler.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,30 @@ set_body(std::string s)
5656
auto
5757
route_params::
5858
spawn(
59-
capy::task<route_result>) ->
59+
capy::task<route_result> t) ->
6060
route_result
6161
{
62-
detail::throw_invalid_argument();
62+
return this->suspend(
63+
[ex = this->ex, t = std::move(t)](resumer resume) mutable
64+
{
65+
auto h = t.release();
66+
67+
h.promise().on_done = [resume, h]()
68+
{
69+
auto& r = h.promise().result;
70+
if(r.index() == 2)
71+
{
72+
auto ep = std::get<2>(r);
73+
h.destroy();
74+
std::rethrow_exception(ep);
75+
}
76+
auto rv = std::move(std::get<1>(r));
77+
h.destroy();
78+
resume(rv);
79+
};
80+
81+
ex.post([h]() { h.resume(); });
82+
});
6383
}
6484

6585
#endif

0 commit comments

Comments
 (0)