mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
allow API post single value (with content-Type:application/json)
This commit is contained in:
@@ -38,12 +38,15 @@ void WebAPIService::webAPIService(AsyncWebServerRequest * request, JsonVariant j
|
|||||||
JsonDocument input_doc; // has no body JSON so create dummy as empty input object
|
JsonDocument input_doc; // has no body JSON so create dummy as empty input object
|
||||||
JsonObject input;
|
JsonObject input;
|
||||||
// if no body then treat it as a secure GET
|
// if no body then treat it as a secure GET
|
||||||
if ((request->method() == HTTP_GET) || (!json.is<JsonObject>())) {
|
if (request->method() == HTTP_GET) {
|
||||||
// HTTP GET
|
// HTTP GET
|
||||||
input = input_doc.to<JsonObject>();
|
input = input_doc.to<JsonObject>();
|
||||||
} else {
|
} else if (json.is<JsonObject>()) {
|
||||||
// HTTP_POST
|
// HTTP_POST
|
||||||
input = json.as<JsonObject>(); // extract values from the json. these will be used as default values
|
input = json.as<JsonObject>(); // extract values from the json. these will be used as default values
|
||||||
|
} else {
|
||||||
|
input = input_doc.to<JsonObject>();
|
||||||
|
input["data"] = json.as<std::string>();
|
||||||
}
|
}
|
||||||
parse(request, input);
|
parse(request, input);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user