Fork of the excellent esp8266-react - https://github.com/rjwats/esp8266-react
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
453 B

  1. #include <RestartService.h>
  2. RestartService::RestartService(AsyncWebServer* server, SecurityManager* securityManager) {
  3. server->on(RESTART_SERVICE_PATH, HTTP_POST,
  4. securityManager->wrapRequest(std::bind(&RestartService::restart, this, std::placeholders::_1), AuthenticationPredicates::IS_ADMIN)
  5. );
  6. }
  7. void RestartService::restart(AsyncWebServerRequest *request) {
  8. request->onDisconnect([](){
  9. ESP.restart();
  10. });
  11. request->send(200);
  12. }