Browse Source

api: allow to handle the request only once

mcspr-patch-1
Maxim Prokhorov 3 years ago
parent
commit
227d3e6620
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      code/espurna/api_impl.h

+ 4
- 1
code/espurna/api_impl.h View File

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


Loading…
Cancel
Save