proper json
This commit is contained in:
parent
bc115ee1b3
commit
2ca0b3ea9b
2 changed files with 9 additions and 9 deletions
|
@ -15,7 +15,7 @@
|
|||
#include <WebSerial.h>
|
||||
#endif
|
||||
#ifdef WEB_OTA_UPDATE
|
||||
#include <AsyncElegantOTA.h>
|
||||
#include <AsyncElegantOTA.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
16
src/main.cpp
16
src/main.cpp
|
@ -159,13 +159,13 @@ String processor(const String& var){
|
|||
|
||||
if(request->hasParam("cardId", true)) {} //This is important, otherwise the sketch will crash if there is no body
|
||||
else {
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{'msg':'No cardId'}");
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"No cardId\"}");
|
||||
request->send(response);
|
||||
}
|
||||
|
||||
if(request->hasParam("desc", true)) {} //This is important, otherwise the sketch will crash if there is no body
|
||||
else {
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{'msg':'No desc'}");
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"No desc\"}");
|
||||
request->send(response);
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ String processor(const String& var){
|
|||
String desc = String(request->arg("desc"));
|
||||
|
||||
if (acl.validateAccess(String(cardId))) {
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{'msg':'Duplicate ACL'}");
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"Duplicate ACL\"}");
|
||||
request->send(response);
|
||||
} else {
|
||||
acl.addUser(cardId, desc);
|
||||
|
@ -190,19 +190,19 @@ String processor(const String& var){
|
|||
|
||||
if(request->hasParam("cardId", true)) {} //This is important, otherwise the sketch will crash if there is no body
|
||||
else {
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{'msg':'No cardId'}");
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"No cardId\"}");
|
||||
request->send(response);
|
||||
}
|
||||
|
||||
if(request->hasParam("newCardId", true)) {} //This is important, otherwise the sketch will crash if there is no body
|
||||
else {
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{'msg':'No newCardId'}");
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "\"msg\":\"No newCardId\"}");
|
||||
request->send(response);
|
||||
}
|
||||
|
||||
if(request->hasParam("desc", true)) {} //This is important, otherwise the sketch will crash if there is no body
|
||||
else {
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{'msg':'No desc'}");
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"No desc\"}");
|
||||
request->send(response);
|
||||
}
|
||||
String cardId = String(request->arg("cardId"));
|
||||
|
@ -220,7 +220,7 @@ String processor(const String& var){
|
|||
|
||||
if(request->hasParam("cardId", true)) {} //This is important, otherwise the sketch will crash if there is no body
|
||||
else {
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{'msg':'No cardId'}");
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"No cardId\"}");
|
||||
request->send(response);
|
||||
}
|
||||
String cardId = String(request->arg("cardId"));
|
||||
|
@ -337,7 +337,7 @@ void setup() {
|
|||
});
|
||||
|
||||
server.onNotFound([](AsyncWebServerRequest *request){
|
||||
request->send(200, "application/json", "{'msg':'The content you are looking for was not found'}");
|
||||
request->send(200, "application/json", "{\"msg\":\"The content you are looking for was not found\"}");
|
||||
});
|
||||
|
||||
// Send a GET request to <ESP_IP>/gpio?output=<inputMessage1>&state=<inputMessage2>
|
||||
|
|
Loading…
Reference in a new issue