mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
Fix nonempty completion handler before middleware call
This commit is contained in:
parent
80bc1cf00a
commit
0b1eb12f60
@ -269,13 +269,19 @@ namespace crow
|
||||
auto& ctx = *reinterpret_cast<typename App::context_t*>(req.middleware_context);
|
||||
auto& container = *reinterpret_cast<typename App::mw_container_t*>(req.middleware_container);
|
||||
|
||||
bool completed = middleware_call_helper<middleware_call_criteria,
|
||||
0, typename App::context_t, typename App::mw_container_t>(container, req, res, ctx);
|
||||
|
||||
if (completed) return;
|
||||
|
||||
auto glob_completion_handler = std::move(res.complete_request_handler_);
|
||||
auto completion_handler = [&ctx, &container, &req, &res, &glob_completion_handler] {
|
||||
res.complete_request_handler_ = [] {};
|
||||
|
||||
middleware_call_helper<middleware_call_criteria,
|
||||
0, typename App::context_t, typename App::mw_container_t>(container, req, res, ctx);
|
||||
|
||||
if (res.completed_)
|
||||
{
|
||||
glob_completion_handler();
|
||||
return;
|
||||
}
|
||||
|
||||
res.complete_request_handler_ = [&ctx, &container, &req, &res, &glob_completion_handler] {
|
||||
after_handlers_call_helper<
|
||||
middleware_call_criteria,
|
||||
std::tuple_size<typename App::mw_container_t>::value - 1,
|
||||
@ -283,7 +289,6 @@ namespace crow
|
||||
typename App::mw_container_t>(container, ctx, req, res);
|
||||
glob_completion_handler();
|
||||
};
|
||||
res.complete_request_handler_ = std::move(completion_handler);
|
||||
|
||||
wrapped_handler_call(req, res, f, std::forward<Args>(args)...);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user