Skip to content

Commit 4e67336

Browse files
committed
Fix 404 route
1 parent 86f4ccf commit 4e67336

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/main.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ void loop() {
179179
const char* method = req["method"];
180180
auto param = req["param"];
181181

182+
bool notFound = false;
183+
182184
if (strcmp(method, "set_rgbw") == 0) {
183185
if (param["time"]) {
184186
state.transitionTime = param["time"].as<unsigned long>();
@@ -204,16 +206,20 @@ void loop() {
204206
} else if (strcmp(method, "get_info") == 0) {
205207
res["mac"] = MAC_ADDRESS;
206208
} else {
209+
notFound = true;
210+
}
211+
212+
if (notFound) {
207213
client.println("HTTP/1.1 404 Not Found");
208214
client.println("Connection: close");
209215
client.println();
210-
}
211-
212-
client.println("HTTP/1.1 200 OK");
213-
client.println("Connection: close");
214-
client.println();
215-
if (!res.isNull()) {
216-
serializeJson(res, client);
216+
} else {
217+
client.println("HTTP/1.1 200 OK");
218+
client.println("Connection: close");
219+
client.println();
220+
if (!res.isNull()) {
221+
serializeJson(res, client);
222+
}
217223
}
218224
} else {
219225
client.println("HTTP/1.1 404 Not Found");

0 commit comments

Comments
 (0)