mirror of
https://github.com/usatiuk/EggbotWireless.git
synced 2025-10-26 16:57:48 +01:00
getStatus api
This commit is contained in:
@@ -9,6 +9,7 @@ class WebAPI {
|
|||||||
private:
|
private:
|
||||||
void handleNotFound();
|
void handleNotFound();
|
||||||
void handlePutCommand();
|
void handlePutCommand();
|
||||||
|
void handleGetStatus();
|
||||||
String getStatusJson();
|
String getStatusJson();
|
||||||
public:
|
public:
|
||||||
WebAPI();
|
WebAPI();
|
||||||
|
|||||||
@@ -29,12 +29,19 @@ void WebAPI::handleNotFound() {
|
|||||||
|
|
||||||
void WebAPI::handlePutCommand() {
|
void WebAPI::handlePutCommand() {
|
||||||
queueManager.putCommand(server.arg("plain").c_str());
|
queueManager.putCommand(server.arg("plain").c_str());
|
||||||
server.send(200, "text/plain", getStatusJson());
|
server.send(200, "application/json", getStatusJson());
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebAPI::handleGetStatus() {
|
||||||
|
server.send(200, "application/json", getStatusJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebAPI::init() {
|
void WebAPI::init() {
|
||||||
server.on("/putCommand", HTTP_POST,
|
server.on("/putCommand", HTTP_POST,
|
||||||
std::bind(&WebAPI::handlePutCommand, this));
|
std::bind(&WebAPI::handlePutCommand, this));
|
||||||
|
server.on("/getStatus", HTTP_GET,
|
||||||
|
std::bind(&WebAPI::handleGetStatus, this));
|
||||||
|
|
||||||
server.onNotFound(std::bind(&WebAPI::handleNotFound, this));
|
server.onNotFound(std::bind(&WebAPI::handleNotFound, this));
|
||||||
server.begin();
|
server.begin();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user