diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 2464ad9dc..689b4bdd6 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -874,6 +874,10 @@ const WebServerDispatch_t WebServerDispatch[] PROGMEM = { #endif // Not FIRMWARE_MINIMAL }; +void WebServer_on(const char * prefix, void (*func)(void), uint8_t method = HTTP_ANY) { + Webserver->on((const __FlashStringHelper *) prefix, (HTTPMethod) method, func); +} + void StartWebserver(int type, IPAddress ipweb) { if (!Settings.web_refresh) { Settings.web_refresh = HTTP_REFRESH_TIME; } @@ -883,13 +887,14 @@ void StartWebserver(int type, IPAddress ipweb) // call `Webserver->on()` on each entry for (uint32_t i=0; ion(uri, (HTTPMethod) method, line.handler); + WebServer_on(uri, line.handler, pgm_read_byte(&line.method)); } Webserver->onNotFound(HandleNotFound); Webserver->on("/u2", HTTP_POST, HandleUploadDone, HandleUploadLoop); // this call requires 2 functions so we keep a direct call diff --git a/tasmota/xdrv_02_mqtt.ino b/tasmota/xdrv_02_mqtt.ino index ffbefc277..0f41cc2d8 100644 --- a/tasmota/xdrv_02_mqtt.ino +++ b/tasmota/xdrv_02_mqtt.ino @@ -1398,7 +1398,7 @@ bool Xdrv02(uint8_t function) WSContentSend_P(HTTP_BTN_MENU_MQTT); break; case FUNC_WEB_ADD_HANDLER: - Webserver->on("/" WEB_HANDLE_MQTT, HandleMqttConfiguration); + WebServer_on(PSTR("/" WEB_HANDLE_MQTT), HandleMqttConfiguration); break; #endif // USE_WEBSERVER case FUNC_COMMAND: diff --git a/tasmota/xdrv_07_domoticz.ino b/tasmota/xdrv_07_domoticz.ino index 411d8894d..2236b124d 100644 --- a/tasmota/xdrv_07_domoticz.ino +++ b/tasmota/xdrv_07_domoticz.ino @@ -638,7 +638,7 @@ bool Xdrv07(uint8_t function) { WSContentSend_P(HTTP_BTN_MENU_DOMOTICZ); break; case FUNC_WEB_ADD_HANDLER: - Webserver->on("/" WEB_HANDLE_DOMOTICZ, HandleDomoticzConfiguration); + WebServer_on(PSTR("/" WEB_HANDLE_DOMOTICZ), HandleDomoticzConfiguration); break; #endif // USE_WEBSERVER case FUNC_MQTT_SUBSCRIBE: diff --git a/tasmota/xdrv_09_timers.ino b/tasmota/xdrv_09_timers.ino index a6b997458..f398b0922 100644 --- a/tasmota/xdrv_09_timers.ino +++ b/tasmota/xdrv_09_timers.ino @@ -928,7 +928,7 @@ bool Xdrv09(uint8_t function) #endif // USE_RULES break; case FUNC_WEB_ADD_HANDLER: - Webserver->on("/" WEB_HANDLE_TIMER, HandleTimerConfiguration); + WebServer_on(PSTR("/" WEB_HANDLE_TIMER), HandleTimerConfiguration); break; #endif // USE_TIMERS_WEB #endif // USE_WEBSERVER diff --git a/tasmota/xdrv_11_knx.ino b/tasmota/xdrv_11_knx.ino index 4524c42d2..1e3a12c7c 100644 --- a/tasmota/xdrv_11_knx.ino +++ b/tasmota/xdrv_11_knx.ino @@ -1271,7 +1271,7 @@ bool Xdrv11(uint8_t function) WSContentSend_P(HTTP_BTN_MENU_KNX); break; case FUNC_WEB_ADD_HANDLER: - Webserver->on("/kn", HandleKNXConfiguration); + WebServer_on(PSTR("/kn"), HandleKNXConfiguration); break; #endif // USE_KNX_WEB_MENU #endif // USE_WEBSERVER diff --git a/tasmota/xdrv_20_hue.ino b/tasmota/xdrv_20_hue.ino index b279b1832..fea0411eb 100644 --- a/tasmota/xdrv_20_hue.ino +++ b/tasmota/xdrv_20_hue.ino @@ -897,7 +897,7 @@ bool Xdrv20(uint8_t function) #endif switch (function) { case FUNC_WEB_ADD_HANDLER: - Webserver->on(F("/description.xml"), HandleUpnpSetupHue); + WebServer_on(PSTR("/description.xml"), HandleUpnpSetupHue); break; } } diff --git a/tasmota/xdrv_21_wemo.ino b/tasmota/xdrv_21_wemo.ino index 30f9e7749..1f52fb474 100644 --- a/tasmota/xdrv_21_wemo.ino +++ b/tasmota/xdrv_21_wemo.ino @@ -353,10 +353,10 @@ bool Xdrv21(uint8_t function) if (devices_present && (EMUL_WEMO == Settings.flag2.emulation)) { switch (function) { case FUNC_WEB_ADD_HANDLER: - Webserver->on(F("/upnp/control/basicevent1"), HTTP_POST, HandleUpnpEvent); - Webserver->on(F("/eventservice.xml"), HandleUpnpService); - Webserver->on(F("/metainfoservice.xml"), HandleUpnpMetaService); - Webserver->on(F("/setup.xml"), HandleUpnpSetupWemo); + WebServer_on(PSTR("/upnp/control/basicevent1"), HandleUpnpEvent, HTTP_POST); + WebServer_on(PSTR("/eventservice.xml"), HandleUpnpService); + WebServer_on(PSTR("/metainfoservice.xml"), HandleUpnpMetaService); + WebServer_on(PSTR("/setup.xml"), HandleUpnpSetupWemo); break; } } diff --git a/tasmota/xdrv_23_zigbee_A_impl.ino b/tasmota/xdrv_23_zigbee_A_impl.ino index 9e4bacd68..3e68b20cc 100644 --- a/tasmota/xdrv_23_zigbee_A_impl.ino +++ b/tasmota/xdrv_23_zigbee_A_impl.ino @@ -1848,7 +1848,7 @@ bool Xdrv23(uint8_t function) #ifdef USE_ZIGBEE_EZSP // GUI xmodem case FUNC_WEB_ADD_HANDLER: - Webserver->on("/" WEB_HANDLE_ZIGBEE_XFER, HandleZigbeeXfer); + WebServer_on(PSTR("/" WEB_HANDLE_ZIGBEE_XFER), HandleZigbeeXfer); break; #endif // USE_ZIGBEE_EZSP #endif // USE_WEBSERVER diff --git a/tasmota/xdrv_28_pcf8574.ino b/tasmota/xdrv_28_pcf8574.ino index 888f34fee..202acffee 100644 --- a/tasmota/xdrv_28_pcf8574.ino +++ b/tasmota/xdrv_28_pcf8574.ino @@ -248,7 +248,7 @@ bool Xdrv28(uint8_t function) WSContentSend_P(HTTP_BTN_MENU_PCF8574); break; case FUNC_WEB_ADD_HANDLER: - Webserver->on("/" WEB_HANDLE_PCF8574, HandlePcf8574); + WebServer_on(PSTR("/" WEB_HANDLE_PCF8574), HandlePcf8574); break; #endif // USE_WEBSERVER } diff --git a/tasmota/xdrv_43_mlx90640.ino b/tasmota/xdrv_43_mlx90640.ino index 88832acc6..35c3942b0 100644 --- a/tasmota/xdrv_43_mlx90640.ino +++ b/tasmota/xdrv_43_mlx90640.ino @@ -611,7 +611,7 @@ bool Xdrv43(uint8_t function) WSContentSend_P(HTTP_BTN_MENU_MLX90640); break; case FUNC_WEB_ADD_HANDLER: - Webserver->on("/mlx", MLX90640HandleWebGui); + WebServer_on(PSTR("/mlx"), MLX90640HandleWebGui); break; #endif // USE_WEBSERVER case FUNC_COMMAND: diff --git a/tasmota/xdrv_81_webcam.ino b/tasmota/xdrv_81_webcam.ino index f56e4c7ff..18eaf04d7 100755 --- a/tasmota/xdrv_81_webcam.ino +++ b/tasmota/xdrv_81_webcam.ino @@ -814,10 +814,10 @@ uint32_t WcSetStreamserver(uint32_t flag) { if (flag) { if (!CamServer) { CamServer = new ESP8266WebServer(81); - CamServer->on("/", HandleWebcamRoot); - CamServer->on("/cam.mjpeg", HandleWebcamMjpeg); - CamServer->on("/cam.jpg", HandleWebcamMjpeg); - CamServer->on("/stream", HandleWebcamMjpeg); + WebServer_on(PSTR("/"), HandleWebcamRoot); + WebServer_on(PSTR("/cam.mjpeg"), HandleWebcamMjpeg); + WebServer_on(PSTR("/cam.jpg"), HandleWebcamMjpeg); + WebServer_on(PSTR("/stream"), HandleWebcamMjpeg); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("CAM: Stream init")); CamServer->begin(); } @@ -896,9 +896,9 @@ void WcLoop(void) { } void WcPicSetup(void) { - Webserver->on("/wc.jpg", HandleImage); - Webserver->on("/wc.mjpeg", HandleImage); - Webserver->on("/snapshot.jpg", HandleImageBasic); + WebServer_on(PSTR("/wc.jpg"), HandleImage); + WebServer_on(PSTR("/wc.mjpeg"), HandleImage); + WebServer_on(PSTR("/snapshot.jpg"), HandleImage); } void WcShowStream(void) { diff --git a/tasmota/xsns_34_hx711.ino b/tasmota/xsns_34_hx711.ino index 8145a5a55..a29eceb2d 100644 --- a/tasmota/xsns_34_hx711.ino +++ b/tasmota/xsns_34_hx711.ino @@ -593,7 +593,7 @@ bool Xsns34(uint8_t function) WSContentSend_P(HTTP_BTN_MENU_HX711); break; case FUNC_WEB_ADD_HANDLER: - Webserver->on("/" WEB_HANDLE_HX711, HandleHxAction); + WebServer_on(PSTR("/" WEB_HANDLE_HX711), HandleHxAction); break; #endif // USE_HX711_GUI #endif // USE_WEBSERVER diff --git a/tasmota/xsns_60_GPS.ino b/tasmota/xsns_60_GPS.ino index e7094887b..7e9b7265d 100644 --- a/tasmota/xsns_60_GPS.ino +++ b/tasmota/xsns_60_GPS.ino @@ -912,7 +912,7 @@ bool Xsns60(uint8_t function) break; #ifdef USE_FLOG case FUNC_WEB_ADD_HANDLER: - Webserver->on("/UBX", UBXsendFile); + WebServer_on(PSTR("/UBX"), UBXsendFile); break; #endif //USE_FLOG case FUNC_JSON_APPEND: diff --git a/tasmota/xsns_75_prometheus.ino b/tasmota/xsns_75_prometheus.ino index c17300f81..1cd95e177 100644 --- a/tasmota/xsns_75_prometheus.ino +++ b/tasmota/xsns_75_prometheus.ino @@ -102,7 +102,7 @@ bool Xsns75(uint8_t function) switch (function) { case FUNC_WEB_ADD_HANDLER: - Webserver->on("/metrics", HandleMetrics); + WebServer_on(PSTR("/metrics"), HandleMetrics); break; } return result;