18#include <drogon/drogon_callbacks.h>
24#ifdef __cpp_impl_coroutine
49 virtual void doFilter(
const HttpRequestPtr &req,
51 FilterChainCallback &&fccb) = 0;
55 void invoke(
const HttpRequestPtr &req,
56 MiddlewareNextCallback &&nextCb,
57 MiddlewareCallback &&mcb)
final
59 auto mcbPtr = std::make_shared<MiddlewareCallback>(std::move(mcb));
62 [mcbPtr](
const HttpResponsePtr &resp) {
65 [nextCb = std::move(nextCb), mcbPtr]()
mutable {
66 nextCb([mcbPtr = std::move(mcbPtr)](
67 const HttpResponsePtr &resp) { (*mcbPtr)(resp); });
80template <
typename T,
bool AutoCreation = true>
84 static constexpr bool isAutoCreation{AutoCreation};
88#ifdef __cpp_impl_coroutine
89template <
typename T,
bool AutoCreation = true>
93 static constexpr bool isAutoCreation{AutoCreation};
94 ~HttpCoroFilter()
override =
default;
96 void doFilter(
const HttpRequestPtr &req,
98 FilterChainCallback &&fccb)
final
102 fcb = std::move(fcb),
104 HttpResponsePtr resp;
107 resp =
co_await doFilter(req);
109 catch (
const std::exception &ex)
111 internal::handleException(ex, req, std::move(fcb));
116 LOG_ERROR <<
"Exception not derived from std::exception";
131 virtual Task<HttpResponsePtr> doFilter(
const HttpRequestPtr &req) = 0;
The base class for all drogon reflection classes.
Definition DrObject.h:34
The abstract base class for filters For more details on the class, see the wiki site (the 'Filter' se...
Definition HttpFilter.h:36
virtual void doFilter(const HttpRequestPtr &req, FilterCallback &&fcb, FilterChainCallback &&fccb)=0
This virtual function should be overridden in subclasses.
The reflection base class template for filters.
Definition HttpFilter.h:82
The abstract base class for middleware.
Definition HttpMiddleware.h:33
Drogon Test is a minimal effort test framework developed because the major C++ test frameworks doesn'...
Definition Attribute.h:23
void async_run(Coro &&coro)
Runs a coroutine from a regular function.
Definition coroutine.h:749
Definition coroutine.h:161