The main class of the framework. Each object of this class is an independent web-application, which could be configured by handlers, middleware etc.
More...
#include <app.h>
The main class of the framework. Each object of this class is an independent web-application, which could be configured by handlers, middleware etc.
This class implements web-application, which is running on given and port. It supports IPv6 and can capture log in the file if given. Use Handlers, Middleware and set Redirects to adjust it.
App::App |
( |
const char * |
ip = "127.0.0.1" , |
|
|
int |
port = 80 , |
|
|
bool |
isIPv6 = false , |
|
|
const char * |
logFilePath = nullptr |
|
) |
| |
|
explicit |
Create a new web application, which is only adjusted to ip address. You can init this and add some handlers etc. to run this
- Parameters
-
ip | text representation of ip address, like 127.0.0.1 or 0:0:0:0:0:0:0:1 (if IPv6) |
port | port in range [0, 65535] |
isIPv6 | set true, if param ip is version 6 |
logFilePath | if you want to create log file, give a file path, or null otherwise |
Create a new web application, by command line arguments using InitParams object
- Parameters
-
params | Give an object params, which was created by InitParams class from command line arguments |
Destructor delete all added handlers and all middleware
void App::addHandler |
( |
Handler * |
handler | ) |
|
To configure your application create and add some handlers
- Parameters
-
handler | object of class Handler (could be inherited) with overridden function exec |
void App::addMiddleware |
( |
Middleware * |
middleware | ) |
|
Add object of class Middleware, which has got overridden function exec to do given operations on every request. All handlers could access to any middleware and perform adjusted actions.
- Parameters
-
middleware | object of class Middleware (could be inherited) |
void App::addPermanentlyRedirect |
( |
const char * |
uri, |
|
|
const char * |
target |
|
) |
| |
Add redirection, which is meant to last forever. The original URL should not be used anymore and that the new one is preferred. Search engine robots trigger an update of the associated URL for the resource in their indexes. (HTTP code 301)
- Parameters
-
uri | original uri path, which is deprecated (outdated) |
target | new uri address of mentioned page |
void App::addRedirect |
( |
const char * |
uri, |
|
|
const char * |
target, |
|
|
int |
code |
|
) |
| |
To adjust any redirection using status code. For example, 304 (Not Modified) redirects a page to the locally cached copy, and 300 (Multiple Choice) is a manual redirection: the body, presented by the browser as a Web page, lists the possible redirection and the user clicks on one to select it.
- Parameters
-
uri | original uri path, which is deprecated (outdated) |
target | new uri address of mentioned page |
code | HTTP code redirection status of response |
void App::addTemporaryRedirect |
( |
const char * |
uri, |
|
|
const char * |
target |
|
) |
| |
Temporary redirect can be used, if for some time the requested resource cannot be accessed from its canonical location, but it can be accessed from another place. Search engine robots don't memorize the new, temporary link. Temporary redirection are also used when creating, updating and deleting resources to present temporary progress pages.
- Parameters
-
uri | original uri path, which is deprecated (outdated) |
target | new uri address of mentioned page |
Use this function to open socket for listening on declared ip address and port. After creating on object you should use this function to startup web-socket
- Returns
- true if ip address and port were valid and available, false - otherwise, please, use another address to continue
Start listening for request. This method startup the system, where on every request from clients all added handlers and middleware create a response and send it to client.
The documentation for this class was generated from the following file:
- /home/travis/build/akrava/web-framework/include/app.h