ESP-LiveControl  1.99.1
HTTP server, AJAX API backend and Vue.js web application implementing self-contained, zero-install WiFi remote control of hardware modules attached to the Espressif ESP32 SoC
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
APIServer Class Reference

AJAX HTTP API server for ESP-AJAX-Lab. More...

#include <api_server.hpp>

Collaboration diagram for APIServer:
Collaboration graph
[legend]

Public Member Functions

 APIServer (AsyncWebServer *http_backend)
 
void set_template (const char *placeholder, const char *replacement)
 
void register_api_cb (const char *cmd_name, CbStringT cmd_callback)
 
void register_api_cb (const char *cmd_name, CbFloatT cmd_callback)
 
void register_api_cb (const char *cmd_name, CbIntT cmd_callback)
 
void register_api_cb (const char *cmd_name, CbVoidT cmd_callback)
 
void begin ()
 

Public Attributes

AsyncWebServer * backend
 
AsyncEventSource * event_source
 
CmdMapT cmd_map
 
TemplateMapT template_map
 
bool reboot_requested
 

Static Public Attributes

static constexpr APIServerConfig srv_conf {}
 

Detailed Description

AJAX HTTP API server for ESP-AJAX-Lab.

Based on ESPAsyncWebServer, see: https://github.com/me-no-dev/ESPAsyncWebServer

This implements higher-level API callbacks on the /cmd endpoint

For details, see README.md

Member Function Documentation

◆ begin()

void APIServer::begin ( )

Start execution, includes starting the ESPAsyncWebServer backend. Do not call this when using WifiManger or when backend has been activated before by other means

Begin operation. This must be called when SPIFFS and Arduino environment is available.

◆ register_api_cb() [1/4]

void APIServer::register_api_cb ( const char *  cmd_name,
CbFloatT  cmd_callback 
)

Setup HTTP request callbacks to a common API endpoint, distinguished by individual command names.

Overload for float argument callbacks:

◆ register_api_cb() [2/4]

void APIServer::register_api_cb ( const char *  cmd_name,
CbIntT  cmd_callback 
)

Setup HTTP request callbacks to a common API endpoint, distinguished by individual command names.

Overload for integer argument callbacks:

◆ register_api_cb() [3/4]

void APIServer::register_api_cb ( const char *  cmd_name,
CbStringT  cmd_callback 
)

Setup HTTP request callbacks to a common API endpoint, distinguished by individual command names.

Overload for string argument callbacks:

◆ register_api_cb() [4/4]

void APIServer::register_api_cb ( const char *  cmd_name,
CbVoidT  cmd_callback 
)

Setup HTTP request callbacks to a common API endpoint, distinguished by individual command names.

Overload for void argument callbacks:

◆ set_template()

void APIServer::set_template ( const char *  placeholder,
const char *  replacement 
)

Set an entry in the template processor string <=> string mapping


The documentation for this class was generated from the following files: