HTTP/1.1 server that accepts connections and dispatches to a router. More...
#include <httpd.hpp>
Public Member Functions | |
| TWebServer (TSocket &&serverSocket, IRouter &router, std::function< void(const std::string &)> logger={}) | |
| Constructs the server. | |
| TVoidTask | Start () |
| Starts the accept loop as a detached TVoidTask. | |
HTTP/1.1 server that accepts connections and dispatches to a router.
Takes ownership of a bound, listening socket. Call Start() to launch the accept loop as a detached TVoidTask.
| TSocket | A bound+listening socket type (e.g. TDefaultPoller::TSocket). |
|
inline |
Constructs the server.
| serverSocket | Bound, listening socket (moved in; owned by the server). |
| router | Request handler; must outlive this server. |
| logger | Optional nginx-style access-log callback. |
|
inline |
Starts the accept loop as a detached TVoidTask.
Runs forever, accepting connections and spawning a per-connection handler coroutine for each. Returns immediately (the loop is detached).
Accept errors are reported only to the logger, so without one they are silent. After an error that is not transient the loop sleeps 100 ms and accepts again.