uncouple generic web stuff into api plugin

This commit is contained in:
2018-10-28 03:21:26 +01:00
parent a8d5cae284
commit 7fa3683ca6
8 changed files with 237 additions and 85 deletions

View File

@@ -1,13 +1,19 @@
#ifndef __WSUTILS_H___
#define __WSUTILS_H___
#ifndef __WebUtils_H___
#define __WebUtils_H___
#include <Arduino.h>
#include <ESPAsyncWebServer.h>
#include <AsyncWebSocket.h>
#include <ESPAsyncTCP.h>
class WsUtils {
class WebUtils {
public:
static String getRequestParameterOrDefault(AsyncWebServerRequest *request, String param, String defaultValue, bool isPost = true){
if(request->hasParam(param, isPost)) {
return request->getParam(param, isPost)->value();
}
return defaultValue;
}
static String parseFrame(AwsEventType type, void * arg, uint8_t *data, size_t len) {
String msg = "";
if(type == WS_EVT_DATA){