Skip to content

Commit aec8e7b

Browse files
committed
Merge remote-tracking branch 'origin/main' into requestmethod-typing
2 parents c032dfe + 5dbf4f7 commit aec8e7b

4 files changed

Lines changed: 60 additions & 3 deletions

File tree

.github/ISSUE_TEMPLATE/issue-report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ body:
6060
id: stack-trace
6161
attributes:
6262
label: Stack Trace
63-
description: Please provide a debug message or error message. If you have a Guru Meditation Error or Backtrace, [please decode it](https://maximeborges.github.io/esp-stacktrace-decoder/).
63+
description: Please provide a debug message or error message. If you have a Guru Meditation Error or Backtrace, [please decode it](https://esphome.github.io/esp-stacktrace-decoder/).
6464
placeholder: For Arduino IDE, Enable Core debug level - Debug on tools menu, then put the serial output here.
6565
validations:
6666
required: true
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// SPDX-License-Identifier: LGPL-3.0-or-later
2+
// Copyright 2016-2026 Hristo Gochkov, Mathieu Carbou, Emil Muratov, Will Miles
3+
4+
//
5+
// HTTP Method usage example and check compatibility with Arduino HTTP Methods
6+
//
7+
8+
#include <Arduino.h>
9+
10+
#if !defined(ESP8266)
11+
// simulate asyncws project being used with another library using Arduino HTTP Methods
12+
#include <HTTP_Method.h>
13+
#endif
14+
15+
#if defined(ESP32) || defined(LIBRETINY)
16+
#include <AsyncTCP.h>
17+
#include <WiFi.h>
18+
#elif defined(ESP8266)
19+
#include <ESP8266WiFi.h>
20+
#include <ESPAsyncTCP.h>
21+
#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
22+
#include <RPAsyncTCP.h>
23+
#include <WiFi.h>
24+
#endif
25+
26+
#include <ESPAsyncWebServer.h>
27+
28+
static AsyncWebServer server(80);
29+
30+
void setup() {
31+
Serial.begin(115200);
32+
33+
#if ASYNCWEBSERVER_WIFI_SUPPORTED
34+
WiFi.mode(WIFI_AP);
35+
WiFi.softAP("esp-captive");
36+
#endif
37+
38+
// curl -v http://192.168.4.1/get-or-post
39+
// curl -v -X POST -d "a=b" http://192.168.4.1/get-or-post
40+
server.on("/get-or-post", AsyncWebRequestMethod::HTTP_GET | AsyncWebRequestMethod::HTTP_POST, [](AsyncWebServerRequest *request) {
41+
request->send(200, "text/plain", "Hello");
42+
});
43+
44+
// curl -v http://192.168.4.1/any
45+
server.on("/any", AsyncWebRequestMethod::HTTP_ALL, [](AsyncWebServerRequest *request) {
46+
request->send(200, "text/plain", "Hello");
47+
});
48+
49+
server.begin();
50+
}
51+
52+
// not needed
53+
void loop() {
54+
delay(100);
55+
}

platformio.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ lib_dir = .
1414
; src_dir = examples/Filters
1515
; src_dir = examples/FlashResponse
1616
; src_dir = examples/HeaderManipulation
17+
; src_dir = examples/Headers
18+
; src_dir = examples/HTTPMethods
1719
; src_dir = examples/Json
1820
; src_dir = examples/LargeResponse
1921
; src_dir = examples/Logging
@@ -38,9 +40,9 @@ src_dir = examples/PerfTests
3840
; src_dir = examples/UploadFlash
3941
; src_dir = examples/URIMatcher
4042
; src_dir = examples/URIMatcherTest
43+
; src_dir = examples/WebDAVMethods
4144
; src_dir = examples/WebSocket
4245
; src_dir = examples/WebSocketEasy
43-
; src_dir = examples/WebDAVMethods
4446

4547
[env]
4648
framework = arduino

src/AsyncJson.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ constexpr static WebRequestMethodComposite JsonHandlerMethods =
117117

118118
#if ARDUINOJSON_VERSION_MAJOR == 6
119119
AsyncCallbackJsonWebHandler::AsyncCallbackJsonWebHandler(AsyncURIMatcher uri, ArJsonRequestHandlerFunction onRequest, size_t maxJsonBufferSize)
120-
: _uri(std::move(uri)), _method(JsonHandlerTypes), _onRequest(onRequest), maxJsonBufferSize(maxJsonBufferSize), _maxContentLength(16384) {}
120+
: _uri(std::move(uri)), _method(JsonHandlerMethods), _onRequest(onRequest), maxJsonBufferSize(maxJsonBufferSize), _maxContentLength(16384) {}
121121
#else
122122
AsyncCallbackJsonWebHandler::AsyncCallbackJsonWebHandler(AsyncURIMatcher uri, ArJsonRequestHandlerFunction onRequest)
123123
: _uri(std::move(uri)), _method(JsonHandlerMethods), _onRequest(onRequest), _maxContentLength(16384) {}

0 commit comments

Comments
 (0)