tufao
1.3.0
An asynchronous web framework for C++ built on top of Qt
|
This class provides a handler to internally (only seen by your application) rewrite the URL. More...
Public Slots | |
bool | handleRequest (Tufao::HttpServerRequest &request, Tufao::HttpServerResponse &response) override |
Changes the request url and returns false. More... | |
Public Member Functions | |
UrlRewriterHandler (const QUrl &url, QObject *parent=0) | |
Constructs a UrlRewriterHandler object. More... | |
void | setUrl (const QUrl &url) |
Sets the URL that will replace the old URL to url . More... | |
QUrl | url () const |
Returns the url used to replace the old URLs. More... | |
Public Member Functions inherited from Tufao::AbstractHttpServerRequestHandler | |
operator std::function< bool (HttpServerRequest &, HttpServerResponse &)>() | |
Implicit conversion operator to std::function functor object. More... | |
virtual bool | handleRequest (Tufao::HttpServerRequest &request, Tufao::HttpServerResponse &response)=0 |
Handles the request using the response object. More... | |
Static Public Member Functions | |
static std::function< bool(HttpServerRequest &, HttpServerResponse &)> | handler (const QUrl &url) |
Returns a handler that don't depends on another object. More... | |
This class provides a handler to internally (only seen by your application) rewrite the URL.
One place where this technique is useful is when you want to use one file to handle the root page of your site through HttpFileServer. This example is illustrated in the image below:
|
explicit |
Constructs a UrlRewriterHandler object.
parent
is passed to the QObject constructor.
url
will be the new url.
|
static |
Returns a handler that don't depends on another object.
The purpose of this alternative handler is to free you of the worry of maintain the UrlRewriterHandler's object (lifetime) while the functor object is being used.
|
overrideslot |
Changes the request
url and returns false.
This method doesn't do anything else.
void Tufao::UrlRewriterHandler::setUrl | ( | const QUrl & | url | ) |
Sets the URL that will replace the old URL to url
.
QUrl Tufao::UrlRewriterHandler::url | ( | ) | const |
Returns the url used to replace the old URLs.