mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-26 13:12:21 +00:00
feat(esp_http_server): Make HTTP(S)_SERVER_EVENT events optional
Make it possible to disable http(s) server events. This improves performance of the server, as http server creates events on every signle read or write to the socket.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
|
||||
static const char *TAG = "example";
|
||||
|
||||
#ifdef CONFIG_ESP_HTTPS_SERVER_EVENTS
|
||||
/* Event handler for catching system events */
|
||||
static void event_handler(void* arg, esp_event_base_t event_base,
|
||||
int32_t event_id, void* event_data)
|
||||
@@ -42,6 +43,7 @@ static void event_handler(void* arg, esp_event_base_t event_base,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // CONFIG_ESP_HTTPS_SERVER_EVENTS
|
||||
|
||||
/* An HTTP GET handler */
|
||||
static esp_err_t root_get_handler(httpd_req_t *req)
|
||||
@@ -257,7 +259,9 @@ void app_main(void)
|
||||
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &connect_handler, &server));
|
||||
ESP_ERROR_CHECK(esp_event_handler_register(ETH_EVENT, ETHERNET_EVENT_DISCONNECTED, &disconnect_handler, &server));
|
||||
#endif // CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||
#ifdef CONFIG_ESP_HTTPS_SERVER_EVENTS
|
||||
ESP_ERROR_CHECK(esp_event_handler_register(ESP_HTTPS_SERVER_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL));
|
||||
#endif // CONFIG_ESP_HTTPS_SERVER_EVENTS
|
||||
|
||||
/* This helper function configures Wi-Fi or Ethernet, as selected in menuconfig.
|
||||
* Read "Establishing Wi-Fi or Ethernet Connection" section in
|
||||
|
||||
Reference in New Issue
Block a user