Skip to content

Commit

Permalink
fix: attach default handler to an endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ZanzyTHEbar committed Apr 6, 2024
1 parent c777bd0 commit c71b7d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion NetworkManager/src/api/rest_api_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ void APIServer::begin() {
[&](AsyncWebServerRequest* request) { handleRequest(request); });

//* Add default JSON handler

// create JSON route
std::string json_url = async_server.api_url;
json_url.append(async_server.json_url);

async_server.server.on(
json_url.c_str(), XHTTP_GET, [&](AsyncWebServerRequest* request) {
request->send(400, MIMETYPE_JSON,
"{\"msg\":\"Invalid Request Type\"}");
});

async_server.server.addHandler(new AsyncCallbackJsonWebHandler(
json_url.c_str(),
[&](AsyncWebServerRequest* request, JsonVariant& json) {
Expand Down
4 changes: 2 additions & 2 deletions NetworkManager/wokwi.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[wokwi]
version = 1
elf = ".pio/build/esp32s3_debug/EasyNetworkManager-v5.4.1-esp32s3_debug-2541372-main.elf"
firmware = ".pio/build/esp32s3_debug/EasyNetworkManager-v5.4.1-esp32s3_debug-2541372-main.bin"
elf = ".pio/build/esp32s3_debug/EasyNetworkManager-v5.4.2-esp32s3_debug-e4c9671-main.elf"
firmware = ".pio/build/esp32s3_debug/EasyNetworkManager-v5.4.2-esp32s3_debug-e4c9671-main.bin"
[[net.forward]]
from = "localhost:8180"
to = "target:80"

0 comments on commit c71b7d4

Please sign in to comment.