mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-07-29 10:02:48 +00:00
merge all URI handlers into a single dispatch function
This commit is contained in:
@@ -25,10 +25,14 @@ uint16_t WebAPIService::api_fails_ = 0;
|
||||
|
||||
WebAPIService::WebAPIService(AsyncWebServer * server, SecurityManager * securityManager)
|
||||
: _securityManager(securityManager) {
|
||||
AsyncCallbackJsonWebHandler * jsonHandler = new AsyncCallbackJsonWebHandler(EMSESP_API_SERVICE_PATH);
|
||||
jsonHandler->setMethod(HTTP_POST | HTTP_GET);
|
||||
jsonHandler->onRequest([this](AsyncWebServerRequest * request, JsonVariant json) { webAPIService(request, json); });
|
||||
server->addHandler(jsonHandler);
|
||||
// parse() does its own per-request admin check (with notoken_api), so no predicate.
|
||||
// /api also matches /api/<device>/<entity> via the route's backward-compatible URI matcher.
|
||||
securityManager->addEndpoint(
|
||||
server,
|
||||
EMSESP_API_SERVICE_PATH,
|
||||
AuthenticationPredicates::NONE_REQUIRED,
|
||||
[this](AsyncWebServerRequest * request, JsonVariant json) { webAPIService(request, json); },
|
||||
HTTP_POST | HTTP_GET);
|
||||
}
|
||||
|
||||
// POST|GET api/
|
||||
|
||||
Reference in New Issue
Block a user