|
FastLED 3.9.15
|
HTTP Server class.
Minimal HTTP/1.0 server with non-blocking I/O. Designed for educational purposes and host-based testing.
Platform Support:
#include <server.h>
Inheritance diagram for fl::asio::http::Server:
Collaboration diagram for fl::asio::http::Server:Classes | |
| struct | ClientConnection |
| struct | RouteEntry |
| class | ServerAsyncRunner |
Public Member Functions | |
| Server () FL_NOEXCEPT | |
| Constructor. | |
| Server (const Server &) FL_NOEXCEPT=delete | |
| ~Server () FL_NOEXCEPT | |
| Destructor (stops server if running) | |
| void | del (const string &path, RouteHandler handler) |
| Convenience method for DELETE routes. | |
| void | get (const string &path, RouteHandler handler) |
| Convenience method for GET routes. | |
| bool | is_running () const |
| Check if server is running. | |
| string | last_error () const |
| Get last error message. | |
| Server & | operator= (const Server &) FL_NOEXCEPT=delete |
| int | port () const |
| Get server port. | |
| void | post (const string &path, RouteHandler handler) |
| Convenience method for POST routes. | |
| void | put (const string &path, RouteHandler handler) |
| Convenience method for PUT routes. | |
| void | route (const string &method, const string &path, RouteHandler handler) |
| Register route handler using fl::function. | |
| bool | start (int port=8080) |
| Start server on specified port. | |
| void | stop () |
| Stop server and close all connections. | |
| size_t | update () |
| Update server (process pending requests non-blocking) | |
Public Member Functions inherited from fl::EngineEvents::Listener | |
| Listener () FL_NOEXCEPT | |
| virtual | ~Listener () FL_NOEXCEPT |
| virtual void | onBeginFrame () FL_NOEXCEPT |
| virtual void | onCanvasUiSet (CLEDController *strip, const ScreenMap &screenmap) FL_NOEXCEPT |
| virtual void | onEndFrame () FL_NOEXCEPT |
| virtual void | onEndShowLeds () FL_NOEXCEPT |
| virtual void | onPlatformPreLoop () FL_NOEXCEPT |
| virtual void | onPlatformPreLoop2 () FL_NOEXCEPT |
| virtual void | onStripAdded (CLEDController *strip, fl::u32 num_leds) FL_NOEXCEPT |
Private Member Functions | |
| void | accept_connections () |
| void | cleanup_stale_connections () |
| void | close_client (size_t index) |
| optional< RouteHandler > | find_handler (const string &method, const string &path) const |
| void | onExit () override |
| size_t | process_requests () |
| optional< Request > | read_request (ClientConnection &client) |
| bool | send_response (int client_fd, const Response &response) |
| bool | setup_listen_socket (int port) |
Private Attributes | |
| fl::unique_ptr< ServerAsyncRunner > | mAsyncRunner |
| vector< ClientConnection > | mClientSockets |
| string | mLastError |
| int | mListenSocket = -1 |
| int | mPort = 0 |
| vector< RouteEntry > | mRoutes |
| bool | mRunning = false |