From 106dbaf9750cc457cb3f602667a18c7b1c588c25 Mon Sep 17 00:00:00 2001 From: RaffaelW Date: Thu, 31 Oct 2024 23:27:07 +0100 Subject: [PATCH] added callback for request body --- src/main.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 39c9646..97e4dcb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -87,6 +87,17 @@ void setup() serializeJson(doc, jsonString); request->send(200, "application/json", jsonString); }); + + server.onRequestBody([](AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) + { + if (request->url() == "/config" && request->method() == HTTP_PUT) { + Serial.printf("[REQUEST]\t%s\r\n", (const char *)data); + + StaticJsonDocument<256> doc; + deserializeJson(doc, data); + request->send(200); + } }); + delay(1000); server.begin(); Serial.println("Server started!"); @@ -95,4 +106,4 @@ void setup() void loop() { artnet.parse(); // check if artnet packet has come and execute callback -} \ No newline at end of file +}