|
@ -3,41 +3,39 @@ |
|
|
API MODULE |
|
|
API MODULE |
|
|
|
|
|
|
|
|
Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com> |
|
|
Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com> |
|
|
|
|
|
Copyright (C) 2020-2021 by Maxim Prokhorov <prokhorov dot max at outlook dot com> |
|
|
|
|
|
|
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
#pragma once |
|
|
#pragma once |
|
|
|
|
|
|
|
|
#include "espurna.h" |
|
|
#include "espurna.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "api_impl.h" |
|
|
#include "web.h" |
|
|
#include "web.h" |
|
|
|
|
|
|
|
|
#if WEB_SUPPORT |
|
|
|
|
|
|
|
|
#include <functional> |
|
|
|
|
|
|
|
|
|
|
|
#if WEB_SUPPORT |
|
|
bool apiAuthenticateHeader(AsyncWebServerRequest*, const String& key); |
|
|
bool apiAuthenticateHeader(AsyncWebServerRequest*, const String& key); |
|
|
bool apiAuthenticateParam(AsyncWebServerRequest*, const String& key); |
|
|
bool apiAuthenticateParam(AsyncWebServerRequest*, const String& key); |
|
|
bool apiAuthenticate(AsyncWebServerRequest*); |
|
|
bool apiAuthenticate(AsyncWebServerRequest*); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
void apiCommonSetup(); |
|
|
void apiCommonSetup(); |
|
|
bool apiEnabled(); |
|
|
bool apiEnabled(); |
|
|
bool apiRestFul(); |
|
|
bool apiRestFul(); |
|
|
String apiKey(); |
|
|
String apiKey(); |
|
|
|
|
|
|
|
|
#endif // WEB_SUPPORT == 1 |
|
|
|
|
|
|
|
|
|
|
|
#if WEB_SUPPORT && API_SUPPORT |
|
|
|
|
|
|
|
|
|
|
|
#include "api_impl.h" |
|
|
|
|
|
|
|
|
|
|
|
#include <functional> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if WEB_SUPPORT |
|
|
using ApiBasicHandler = std::function<bool(ApiRequest&)>; |
|
|
using ApiBasicHandler = std::function<bool(ApiRequest&)>; |
|
|
using ApiJsonHandler = std::function<bool(ApiRequest&, JsonObject& reponse)>; |
|
|
using ApiJsonHandler = std::function<bool(ApiRequest&, JsonObject& reponse)>; |
|
|
|
|
|
|
|
|
void apiRegister(const String& path, ApiBasicHandler&& get, ApiBasicHandler&& put); |
|
|
void apiRegister(const String& path, ApiBasicHandler&& get, ApiBasicHandler&& put); |
|
|
void apiRegister(const String& path, ApiJsonHandler&& get, ApiJsonHandler&& put); |
|
|
void apiRegister(const String& path, ApiJsonHandler&& get, ApiJsonHandler&& put); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
void apiSetup(); |
|
|
void apiSetup(); |
|
|
|
|
|
|
|
|
bool apiError(ApiRequest&); |
|
|
bool apiError(ApiRequest&); |
|
|
bool apiOk(ApiRequest&); |
|
|
bool apiOk(ApiRequest&); |
|
|
|
|
|
|
|
|
#endif // API_SUPPORT == 1 |
|
|
|