|
ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
|
Simple single-threaded HTTP server. More...
#include <src/tooling/query/http_server.h>
Public Member Functions | |
| HttpServer () | |
| ~HttpServer () | |
| HttpServer (const HttpServer &)=delete | |
| HttpServer & | operator= (const HttpServer &)=delete |
| void | addRoute (const std::string &method, const std::string &path, RouteHandler handler) |
| Add a route handler. | |
| void | setDefaultHandler (RouteHandler handler) |
| Set a default handler for unmatched routes. | |
| bool | start (uint16_t port) |
| Start the server. | |
| void | stop () |
| Stop the server. | |
| bool | isRunning () const |
| Check if server is running. | |
| uint16_t | port () const |
| Get the port the server is listening on. | |
| const std::string & | lastError () const |
| Get the last error message. | |
| bool | processOneRequest () |
| Process one request (blocking) | |
Simple single-threaded HTTP server.
Definition at line 162 of file http_server.h.
| ascii_query::HttpServer::HttpServer | ( | ) |
Definition at line 111 of file http_server.cpp.
References ascii_query::HttpResponse::notFound().
| ascii_query::HttpServer::~HttpServer | ( | ) |
Definition at line 122 of file http_server.cpp.
References stop().
|
delete |
| void ascii_query::HttpServer::addRoute | ( | const std::string & | method, |
| const std::string & | path, | ||
| RouteHandler | handler | ||
| ) |
Add a route handler.
| method | HTTP method (GET, POST, etc.) |
| path | URL path (exact match) |
| handler | Handler function |
Definition at line 130 of file http_server.cpp.
|
inline |
Check if server is running.
Definition at line 200 of file http_server.h.
|
inline |
Get the last error message.
Definition at line 214 of file http_server.h.
Referenced by main().
|
delete |
|
inline |
Get the port the server is listening on.
Definition at line 207 of file http_server.h.
Referenced by start().
| bool ascii_query::HttpServer::processOneRequest | ( | ) |
Process one request (blocking)
Used for testing or manual control. Normally you'd call start() instead.
Definition at line 230 of file http_server.cpp.
References INVALID_SOCKET_VAL.
| void ascii_query::HttpServer::setDefaultHandler | ( | RouteHandler | handler | ) |
Set a default handler for unmatched routes.
| handler | Handler function |
Definition at line 134 of file http_server.cpp.
Start the server.
| port | Port to listen on |
Definition at line 136 of file http_server.cpp.
References close_socket, INVALID_SOCKET_VAL, and port().
Referenced by main().
| void ascii_query::HttpServer::stop | ( | ) |
Stop the server.
Definition at line 187 of file http_server.cpp.
References close_socket.
Referenced by main(), and ~HttpServer().