Function registerSyncAdvice

Synopsis

#include <lib/inc/drogon/HttpAppFramework.h>

virtual HttpAppFramework & registerSyncAdvice(const std::function< HttpResponsePtr(const HttpRequestPtr &)> &advice)=0

Description

Register a synchronous advice.

Parameters:

advice - is called immediately after the request is created. If a no-empty response is returned by the advice, it is sent to the client and no handler is invoked.

Note
The following diagram shows the location of the AOP join points during http request processing.
                   +-----------+                             +----------+
                   |  Request  |                             | Response |
                   +-----------+                             +----------+
                         |                                         ^
                         v                                         |
         sync join point o----------->[HttpResponsePtr]----------->+
                         |                                         |
                         v                                         |
  Pre-routing join point o----------->[Advice callback]----------->+
                         |                                         |
                         v         Invalid path                    |
                   [Find Handler]---------------->[404]----------->+
                         |                                         |
                         v                                         |
 Post-routing join point o----------->[Advice callback]----------->+
                         |                                         |
                         v        Invalid method                   |
                   [Check Method]---------------->[405]----------->+
                         |                                         |
                         v                                         |
                     [Filters]------->[Filter callback]----------->+
                         |                                         |
                         v             Y                           |
                [Is OPTIONS method?]------------->[200]----------->+
                         |                                         |
                         v                                         |
 Pre-handling join point o----------->[Advice callback]----------->+
                         |                                         |
                         v                                         |
                     [Handler]                                     |
                         |                                         |
                         v                                         |
Post-handling join point o---------------------------------------->+

Mentioned in

Source

Line 257 in lib/inc/drogon/HttpAppFramework.h.






Add Discussion as Guest

Log in to DocsForge