mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2025-12-13 19:12:10 +01:00
Add preflight responses for PUTS #87
This commit is contained in:
parent
d5a237acea
commit
56abde3175
2 changed files with 6 additions and 1 deletions
Binary file not shown.
7
Web.cpp
7
Web.cpp
|
|
@ -267,6 +267,8 @@ void Web::begin() {
|
||||||
obj["serverId"] = settings.serverId;
|
obj["serverId"] = settings.serverId;
|
||||||
obj["version"] = settings.fwVersion;
|
obj["version"] = settings.fwVersion;
|
||||||
obj["model"] = "ESPSomfyRTS";
|
obj["model"] = "ESPSomfyRTS";
|
||||||
|
obj["authType"] = static_cast<uint8_t>(settings.Security.type);
|
||||||
|
obj["permissions"] = settings.Security.permissions;
|
||||||
JsonArray arrShades = obj.createNestedArray("shades");
|
JsonArray arrShades = obj.createNestedArray("shades");
|
||||||
somfy.toJSONShades(arrShades);
|
somfy.toJSONShades(arrShades);
|
||||||
JsonArray arrGroups = obj.createNestedArray("groups");
|
JsonArray arrGroups = obj.createNestedArray("groups");
|
||||||
|
|
@ -278,7 +280,7 @@ void Web::begin() {
|
||||||
});
|
});
|
||||||
apiServer.on("/shades", []() { webServer.handleGetShades(apiServer); });
|
apiServer.on("/shades", []() { webServer.handleGetShades(apiServer); });
|
||||||
apiServer.on("/groups", []() { webServer.handleGetGroups(apiServer); });
|
apiServer.on("/groups", []() { webServer.handleGetGroups(apiServer); });
|
||||||
|
apiServer.on("/login", []() { webServer.handleLogin(apiServer); });
|
||||||
apiServer.onNotFound([]() {
|
apiServer.onNotFound([]() {
|
||||||
Serial.print("Request 404:");
|
Serial.print("Request 404:");
|
||||||
HTTPMethod method = apiServer.method();
|
HTTPMethod method = apiServer.method();
|
||||||
|
|
@ -309,6 +311,7 @@ void Web::begin() {
|
||||||
apiServer.on("/controller", []() { webServer.handleController(apiServer); });
|
apiServer.on("/controller", []() { webServer.handleController(apiServer); });
|
||||||
apiServer.on("/shadeCommand", []() {
|
apiServer.on("/shadeCommand", []() {
|
||||||
webServer.sendCORSHeaders();
|
webServer.sendCORSHeaders();
|
||||||
|
if(server.method() == HTTP_OPTIONS) { server.send(200, "OK"); return; }
|
||||||
HTTPMethod method = apiServer.method();
|
HTTPMethod method = apiServer.method();
|
||||||
uint8_t shadeId = 255;
|
uint8_t shadeId = 255;
|
||||||
uint8_t target = 255;
|
uint8_t target = 255;
|
||||||
|
|
@ -376,6 +379,7 @@ void Web::begin() {
|
||||||
});
|
});
|
||||||
apiServer.on("/groupCommand", []() {
|
apiServer.on("/groupCommand", []() {
|
||||||
webServer.sendCORSHeaders();
|
webServer.sendCORSHeaders();
|
||||||
|
if(server.method() == HTTP_OPTIONS) { server.send(200, "OK"); return; }
|
||||||
HTTPMethod method = apiServer.method();
|
HTTPMethod method = apiServer.method();
|
||||||
uint8_t groupId = 255;
|
uint8_t groupId = 255;
|
||||||
uint8_t repeat = 1;
|
uint8_t repeat = 1;
|
||||||
|
|
@ -435,6 +439,7 @@ void Web::begin() {
|
||||||
});
|
});
|
||||||
apiServer.on("/tiltCommand", []() {
|
apiServer.on("/tiltCommand", []() {
|
||||||
webServer.sendCORSHeaders();
|
webServer.sendCORSHeaders();
|
||||||
|
if(server.method() == HTTP_OPTIONS) { server.send(200, "OK"); return; }
|
||||||
HTTPMethod method = apiServer.method();
|
HTTPMethod method = apiServer.method();
|
||||||
uint8_t shadeId = 255;
|
uint8_t shadeId = 255;
|
||||||
uint8_t target = 255;
|
uint8_t target = 255;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue