Crow/docs/guides/middleware.md
The-EDev 23648445f3 Changed documentation. a lot.
Added mkdocs documentation.
Altered doxygen generation (doxyfile and shell script) to work with mkdocs.
Removed the whole html folder thing for docs, now the files reside in the root gh-pages branch.
New readme.
2020-11-28 17:28:47 +03:00

1.1 KiB

Any middleware requires following 3 members: ##struct context Storing data for the middleware; can be read from another middleware or handlers

##before_handle Called before handling the request.
If res.end() is called, the operation is halted. (after_handle will still be called)
2 signatures:
#!cpp void before_handle(request& req, response& res, context& ctx) if you only need to access this middleware's context.

template <typename AllContext>
void before_handle(request& req, response& res, context& ctx, AllContext& all_ctx)

You can access other middlewares' context by calling #!cpp all_ctx.template get<MW>()
#!cpp ctx == all_ctx.template get<CurrentMiddleware>()

##after_handle Called after handling the request.

#!cpp void after_handle(request& req, response& res, context& ctx)

template <typename AllContext>
void after_handle(request& req, response& res, context& ctx, AllContext& all_ctx)



This was pulled from cookie_parser.h. Further Editing required, possibly use parts of @ipkn's wiki page.