Simple HTTP server implementation using uvco coroutines and promises.
◆ HttpHandler
◆ httpServer()
Run a simple HTTP server on the given TcpServer, serving the routes defined by the supplied Router instance. Never returns, unless an exception is thrown while accepting a connection or spawning a task.
208 {
209 auto streamPromise = server.
listen();
210
212 while (auto stream = co_await streamPromise.next()) {
214 }
215}
MultiPromise< StreamType > listen(int backlog=128)
Definition stream_server_base_impl.cc:144
static std::unique_ptr< TaskSet > create()
Definition combinators.cc:163
Promise< void > connectionHandler(TcpStream stream, const Router &router)
Definition http_server.cc:159
◆ notFoundHandler()
A handler returning a 404 error.
49 {
53 response.
body =
"Not Found";
54 co_return response;
55}
Definition http_server.h:31
std::string statusMessage
Definition http_server.h:33
std::string body
Definition http_server.h:35
int statusCode
Definition http_server.h:32