Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions ESPWebThingAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,16 @@ class WebThingAdapter {
DefaultHeaders::Instance().addHeader("Access-Control-Allow-Origin", "*");
DefaultHeaders::Instance().addHeader("Access-Control-Allow-Methods",
"GET, POST, PUT, DELETE, OPTIONS");
DefaultHeaders::Instance().addHeader(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept");

this->server.onNotFound(std::bind(&WebThingAdapter::handleUnknown, this,
std::placeholders::_1));

this->server.on("/*", HTTP_OPTIONS,
std::bind(&WebThingAdapter::handleOptions, this,
std::placeholders::_1));
this->server.on("/", HTTP_GET,
std::bind(&WebThingAdapter::handleThings, this,
std::placeholders::_1));
Expand Down Expand Up @@ -333,6 +339,13 @@ class WebThingAdapter {
request->send(404);
}

void handleOptions(AsyncWebServerRequest *request) {
if (!verifyHost(request)) {
return;
}
request->send(204);
}

void handleThings(AsyncWebServerRequest *request) {
if (!verifyHost(request)) {
return;
Expand Down
2 changes: 2 additions & 0 deletions EthernetWebThingAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ class WebThingAdapter {
client.println("Access-Control-Allow-Origin: *");
client.println(
"Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
client.println("Access-Control-Allow-Headers: "
"Origin, X-Requested-With, Content-Type, Accept");
client.println("Content-Type: application/json");
client.println("Connection: close");
client.println();
Expand Down
2 changes: 2 additions & 0 deletions WiFi101WebThingAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ class WebThingAdapter {
client.println("Access-Control-Allow-Origin: *");
client.println(
"Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
client.println("Access-Control-Allow-Headers: "
"Origin, X-Requested-With, Content-Type, Accept");
client.println("Content-Type: application/json");
client.println("Connection: close");
client.println();
Expand Down
24 changes: 0 additions & 24 deletions examples/PlatformIO/TextDisplay/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,6 @@ lib_deps =
Adafruit SSD1306
monitor_speed = 115200

[env:d1]
platform = espressif8266
board = d1
framework = arduino
lib_deps =
${global.lib_deps}
ESP Async WebServer
lib_ignore = WiFi101
lib_ldf_mode = deep+
monitor_speed = ${global.monitor_speed}

[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino
lib_deps =
${global.lib_deps}
ESP Async WebServer
lib_ignore =
ArduinoMDNS
WiFi101
lib_ldf_mode = deep+
monitor_speed = ${global.monitor_speed}

[env:esp32dev]
platform = espressif32
board = esp32dev
Expand Down
4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "webthing-arduino",
"description": "A library for creating Web Things using the Web of Things API. Runs on ESP8266, ESP32, Ethernet, and WiFi101-compatible boards. Compatible with the Mozilla WebThings Gateway.",
"keywords": "Communication",
"version": "0.11.1",
"version": "0.11.2",
"authors": {
"name": "Mozilla IoT <iot@mozilla.com>"
},
Expand All @@ -14,7 +14,7 @@
"license": "Mozilla Public License Version 2.0",
"platforms": "espressif8266,espressif32,atmelavr",
"dependencies": {
"ArduinoJson": "6.13.0"
"ArduinoJson": "6.15.0"
},
"export": {
"include":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=webthing-arduino
version=0.11.1
version=0.11.2
author=Mozilla IoT <iot@mozilla.com>
maintainer=James Hobin <hobinjk@gmail.com>
sentence=A library for creating Web Things using the Web of Things API
Expand Down