Skip to content

Commit

Permalink
changed some HTTP error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
KipK committed May 27, 2023
1 parent e6ec93e commit 6a1cb56
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/web_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ handleScheduleGet(MongooseHttpServerRequest *request, MongooseHttpServerResponse
response->setCode(200);
serializeJson(doc, *response);
} else {
response->setCode(200);
response->setCode(404);
response->print("{\"msg\":\"Not found\"}");
}
}
Expand Down Expand Up @@ -650,7 +650,7 @@ void handleLimitGet(MongooseHttpServerRequest *request, MongooseHttpServerRespon
limit.get().serialize(response);
} else {
response->setCode(200);
response->print("{\"msg\":\"no limit\"}");
response->print("{}");
}
}

Expand All @@ -664,7 +664,7 @@ void handleLimitPost(MongooseHttpServerRequest *request, MongooseHttpServerRespo
// todo: mqtt_publish_limit(); // update limit props to mqtt
} else {
// unused for now
response->setCode(500);
response->setCode(400);
response->print("{\"msg\":\"failed to parse JSON\"}");
}
}
Expand All @@ -675,7 +675,6 @@ void handleLimitDelete(MongooseHttpServerRequest *request, MongooseHttpServerRes
if (limit.clear()) {
response->setCode(200);
response->print("{\"msg\":\"done\"}");
// todo: mqtt_publish_limit(); // update limit props to mqtt
} else {
response->setCode(500);
response->print("{\"msg\":\"failed\"}");
Expand Down Expand Up @@ -776,7 +775,7 @@ void handleEmeter(MongooseHttpServerRequest *request)
props.serialize(response);
} else {
response->setCode(200);
response->print("{\"msg\":\"No manual override\"}");
response->print("{}");
}
}

Expand All @@ -796,7 +795,7 @@ void handleOverridePost(MongooseHttpServerRequest *request, MongooseHttpServerRe
response->print("{\"msg\":\"Failed to claim manual overide\"}");
}
} else {
response->setCode(500);
response->setCode(400);
response->print("{\"msg\":\"Failed to parse JSON\"}");
}
}
Expand Down Expand Up @@ -917,12 +916,12 @@ handleRestart(MongooseHttpServerRequest *request) {
}
}
else {
response->setCode(405);
response->setCode(400);
response->print("{\"msg\":\"wrong payload\"}");
request->send(response);
}
} else {
response->setCode(405);
response->setCode(400);
response->print("{\"msg\":\"Couldn't parse json\"}");
request->send(response);
}
Expand Down

0 comments on commit 6a1cb56

Please sign in to comment.