Function forward


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

virtual void forward(const HttpRequestPtr &req, std::function< void(const HttpResponsePtr &)> &&callback, const std::string &hostString="", double timeout=0)=0


Forward the http request.


req - the HTTP request to be forwarded;

hostString - is the address where the request is forwarded. The following strings are valid for the parameter:

timeout - See the timeout parameter of the sendRequest method of the HttpClient class. this parameter is only valid when the hostString is not empty.

callback - is called when the response is created.

If the hostString parameter is empty, the request is handled by the same application, so in this condition one should modify the path of the req parameter before forwarding to avoid infinite loop processing.
This method can be used to implement reverse proxy or redirection on the server side.


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

Add Discussion as Guest

Log in to DocsForge