Function forward

Synopsis

#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

Description

Forward the http request.

Parameters:

req - the HTTP request to be forwarded;

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

https://www.baidu.com
http://www.baidu.com
https://127.0.0.1:8080/
http://127.0.0.1
http://[::1]:8080/
Parameters:

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.

Note
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.

Source

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






Add Discussion as Guest

Log in to DocsForge