|
join 1.0
lightweight network framework library
|
basic HTTP server. More...
#include <httpserver.hpp>


Public Types | |
| using | Worker = BasicHttpWorker <Protocol> |
| using | Content = BasicHttpContent <Protocol> |
| using | Handler = typename Content::Handler |
| using | Access = typename Content::Access |
| using | Endpoint = typename Protocol::Endpoint |
| using | Socket = typename Protocol::Socket |
| using | Acceptor = typename Protocol::Acceptor |
Public Member Functions | |
| BasicHttpServer (size_t workers=std::thread::hardware_concurrency()) | |
| create the HTTP server instance. | |
| BasicHttpServer (const BasicHttpServer &other)=delete | |
| create instance by copy. | |
| BasicHttpServer & | operator= (const BasicHttpServer &other)=delete |
| assign instance by copy. | |
| BasicHttpServer (BasicHttpServer &&other)=delete | |
| create instance by move. | |
| BasicHttpServer & | operator= (BasicHttpServer &&other)=delete |
| assign instance by move. | |
| virtual | ~BasicHttpServer () |
| destroy the HTTP server. | |
| int | create (const Endpoint &endpoint) noexcept |
| create server. | |
| void | close () noexcept |
| close server. | |
| virtual Socket | accept () const |
| accept new connection. | |
| void | baseLocation (const std::string &path) |
| set file base location. | |
| const std::string & | baseLocation () const |
| get file base location. | |
| void | keepAlive (std::chrono::seconds timeout, int max=1000) |
| set HTTP keep alive. | |
| std::chrono::seconds | keepAliveTimeout () const |
| get HTTP keep alive timeout. | |
| int | keepAliveMax () const |
| get HTTP keep alive max. | |
| virtual std::string | scheme () const |
| get scheme. | |
| Content * | addDocumentRoot (const std::string &dir, const std::string &name, const Access &access=nullptr) |
| map an URL to filesystem adding URL path to the base location. | |
| Content * | addAlias (const std::string &dir, const std::string &name, const std::string &alias, const Access &access=nullptr) |
| map an URL to filesystem replacing URL path by the specified path. | |
| Content * | addExecute (const HttpMethod methods, const std::string &dir, const std::string &name, const Handler &handler, const Access &access=nullptr) |
| map an URL to a callback. | |
| Content * | addRedirect (const std::string &dir, const std::string &name, const std::string &location, const Access &access=nullptr) |
| map an URL to a redirection. | |
Protected Member Functions | |
| Content * | findContent (HttpMethod method, const std::string &path) const |
| find content. | |
Protected Attributes | |
| Acceptor | _acceptor |
| acceptor. | |
| int | _event = -1 |
| gracefully stop all workers. | |
| size_t | _nworkers |
| number of workers. | |
| std::vector< std::unique_ptr< Worker > > | _workers |
| workers. | |
| Mutex | _mutex |
| accept protection mutex. | |
| std::vector< std::unique_ptr< Content > > | _contents |
| contents. | |
| std::string | _baseLocation |
| base location. | |
| std::chrono::seconds | _keepTimeout |
| keep alive timeout. | |
| int | _keepMax = 1000 |
| keep alive max. | |
| Cache | _cache |
| file cache. | |
| friend | Worker |
| friendship with worker. | |
basic HTTP server.
| using join::BasicHttpServer< Protocol >::Acceptor = typename Protocol::Acceptor |
| using join::BasicHttpServer< Protocol >::Access = typename Content::Access |
| using join::BasicHttpServer< Protocol >::Content = BasicHttpContent <Protocol> |
| using join::BasicHttpServer< Protocol >::Endpoint = typename Protocol::Endpoint |
| using join::BasicHttpServer< Protocol >::Handler = typename Content::Handler |
| using join::BasicHttpServer< Protocol >::Socket = typename Protocol::Socket |
| using join::BasicHttpServer< Protocol >::Worker = BasicHttpWorker <Protocol> |
|
inline |
create the HTTP server instance.
| workers | number of worker threads. |
|
delete |
create instance by copy.
| other | object to copy. |
|
delete |
create instance by move.
| other | object to move. |
|
inlinevirtual |
destroy the HTTP server.
|
inlinevirtual |
accept new connection.
Reimplemented in join::BasicHttpSecureServer< Protocol >.
|
inline |
map an URL to filesystem replacing URL path by the specified path.
| dir | directory. |
| name | file name. |
| alias | corresponding file system path. |
| access | access handler. |
|
inline |
map an URL to filesystem adding URL path to the base location.
| dir | directory. |
| name | file name. |
| access | access handler. |
|
inline |
map an URL to a callback.
| methods | allowed methods. |
| dir | directory. |
| name | file name. |
| handler | content handler. |
| access | access handler. |
|
inline |
map an URL to a redirection.
| dir | directory. |
| name | file name. |
| location | location where to do the redirection. |
| access | access handler. |
|
inline |
get file base location.
|
inline |
set file base location.
| path | file base location path. |
|
inlinenoexcept |
close server.
|
inlinenoexcept |
create server.
| endpoint | endpoint to assign to the server. |
|
inlineprotected |
find content.
| method | method. |
| path | resource path. |
|
inline |
set HTTP keep alive.
| timeout | keep alive timeout (default 10 secs). |
| max | keep alive max (default 1000). |
|
inline |
get HTTP keep alive max.
|
inline |
get HTTP keep alive timeout.
|
delete |
assign instance by move.
| other | object to move. |
|
delete |
assign instance by copy.
| other | object to copy. |
|
inlinevirtual |
|
protected |
acceptor.
|
protected |
base location.
|
protected |
file cache.
|
protected |
contents.
|
protected |
gracefully stop all workers.
|
protected |
keep alive max.
|
protected |
keep alive timeout.
|
protected |
accept protection mutex.
|
protected |
number of workers.
|
protected |
workers.
|
protected |
friendship with worker.