|
@ -111,6 +111,7 @@ struct ApiRequest { |
|
|
|
|
|
|
|
|
template <typename T> |
|
|
template <typename T> |
|
|
void handle(T&& handler) { |
|
|
void handle(T&& handler) { |
|
|
|
|
|
if (_done) return; |
|
|
_done = true; |
|
|
_done = true; |
|
|
handler(&_request); |
|
|
handler(&_request); |
|
|
} |
|
|
} |
|
@ -143,12 +144,14 @@ struct ApiRequest { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void send(const String& payload) { |
|
|
void send(const String& payload) { |
|
|
|
|
|
if (_done) return; |
|
|
|
|
|
_done = true; |
|
|
|
|
|
|
|
|
if (payload.length()) { |
|
|
if (payload.length()) { |
|
|
_request.send(200, "text/plain", payload); |
|
|
_request.send(200, "text/plain", payload); |
|
|
} else { |
|
|
} else { |
|
|
_request.send(204); |
|
|
_request.send(204); |
|
|
} |
|
|
} |
|
|
_done = true; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool done() const { |
|
|
bool done() const { |
|
|