-
Notifications
You must be signed in to change notification settings - Fork 3
RaftWebServerSysMod
Rob Dobson edited this page May 3, 2026
·
1 revision
Built-in SysMod that hosts an HTTP server, exposes the REST API over HTTP, optionally serves static files, and registers WebSocket channels with the Comms Channels layer.
- HTTP server on a configurable port with a configurable REST API path prefix.
-
REST API bridge — every endpoint registered via
RestAPIEndpointManager::addEndpoint()is reachable asGET/POST/PUT/DELETE <prefix>/<endpoint>.... - Static file serving from any mounted file system (LittleFS / SPIFFS / SD).
-
WebSocket channels — each entry in the
websocketsarray becomes one or more comms channels using a chosen protocol codec. -
webcertsREST endpoint for uploading TLS certificates.
Place a WebServer block in the SysType SysMods array. Typical values:
| Key | Default | Meaning |
|---|---|---|
enable |
false |
Master switch |
webServerPort |
80 |
TCP listen port |
apiPrefix |
"api/" |
Path prefix for REST endpoints — api/subscription etc. |
fileServer |
true |
Enable static file handler |
numConnSlots |
platform default | Max concurrent HTTP connections |
stdRespHeaders |
[] |
Header lines added to every response |
staticFilePaths |
"/=/<defaultFS>,/files/local=/local,/files/sd=/sd" |
Comma-separated urlPath=fsPath pairs |
websockets |
[] |
Array of websocket configs (see below) |
taskCore, taskPriority, taskStack
|
platform defaults | Web server task |
sendMax |
platform default | Max outbound buffer length |
clearPendingMs |
0 |
If > 0, drop pending tx after this many ms |
| Key | Default | Meaning |
|---|---|---|
pfix |
"ws" |
URL path prefix and channel interface name |
pcol |
"RICSerial" |
Protocol codec to attach (RICSerial, RICFrame, RICJSON) |
maxConn |
impl-defined | Max simultaneous websocket connections |
pingMs |
impl-defined | Ping interval |
txQueueMax |
impl-defined | Outbound queue depth |
Each connection slot is registered with CommsChannelManager as a channel named <pfix>_<idx>, so connection 0 to pfix:"ws" becomes channel ws_0. See Comms Channels.
| Endpoint | Method | Purpose |
|---|---|---|
webcerts/set |
POST | Upload TLS certificates (body = JSON document) |
Every other endpoint visible over HTTP comes from other SysMods registering with RestAPIEndpointManager. The web server simply forwards.
void serveStaticFiles(const char* servePaths, const char* cacheControl = nullptr);
void enableServerSideEvents(const String& eventsURL);
void sendServerSideEvent(const char* eventContent, const char* eventGroup);These are typically called from your application's setup() after RaftCoreApp::setup().
- Adding REST API Endpoints
- Communications Stack Overview
- Comms Channels
- Network Manager SysMod — required for an active network interface
Getting Started
- Quick Start
- Architecture at a Glance
- Writing Your First SysMod
- Adding a Comms Channel
- Adding an I2C Device Type
- PlatformIO / Arduino
Scaffolding & Building
- Raft CLI
- SysTypes
- Top-Level SysType
- Build Process
- WebUI Build Pipeline
- File System
- Partitions & Flash
- Local Dev Libraries
- Library Developer Guide
Architecture
Built-in SysMods
- NetworkManager
- BLEManager
- WebServer
- MQTTManager
- SerialConsole
- CommandSerial
- CommandSocket
- CommandFile
- FileManager
- LogManager
- ESPOTAUpdate
- StatePublisher
- Remote Logging
- Data Source Registration
Comms & Protocols
- Stack Overview
- Comms Channels
- ProtocolExchange
- RICREST Protocol
- Real-Time Streams
- Adding REST Endpoints
- Built-in REST Endpoints
- File Download (OKTO)
- OTA Update Flow
Devices & Buses
- DeviceManager
- Device Manager REST API
- Device Factory & Classes
- Device Type Records
- Adding an I2C Device Type
- Device Data Publishing
- Data Logger
- I2C Bus
- I2C Device Scanning
- I2C ID & Polling
- MotorControl Overview
- MotorControl Config
- MotorControl Commands
Helpers
Reference
{ "name": "WebServer", "enable": 1, "webServerPort": 80, "apiPrefix": "api/", "fileServer": 1, "numConnSlots": 6, "stdRespHeaders": [ "Access-Control-Allow-Origin: *" ], "staticFilePaths": "/=/local,/files/sd=/sd", "websockets": [ { "pfix": "ws", "pcol": "RICSerial", "maxConn": 4, "txQueueMax": 20, "pingMs": 30000 } ], "taskCore": 0, "taskPriority": 5, "taskStack": 5000, "sendMax": 5000, "clearPendingMs": 0 }