ChaosDMX
Open-Source DMX-Interface
Loading...
Searching...
No Matches
web_server.h File Reference

Simple HTTP web server component for ESP32 with async FreeRTOS support. More...

#include "esp_http_server.h"
Include dependency graph for web_server.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  webserver_config_t
 Web server configuration structure. More...

Functions

httpd_handle_t webserver_start (const webserver_config_t *config)
 Initialize and start the HTTP web server.
void webserver_stop (httpd_handle_t server)
 Stop the web server and cleanup resources.
esp_err_t webserver_register_handler (httpd_handle_t server, const httpd_uri_t *uri_handler)
 Register a custom URI handler.

Detailed Description

Simple HTTP web server component for ESP32 with async FreeRTOS support.

Definition in file web_server.h.

Function Documentation

◆ webserver_register_handler()

esp_err_t webserver_register_handler ( httpd_handle_t server,
const httpd_uri_t * uri_handler )

Register a custom URI handler.

This allows dynamic registration of API endpoints and other custom handlers.

Parameters
serverHTTP server handle.
uri_handlerPointer to httpd_uri_t structure.
Returns
ESP_OK on success, error code otherwise.

Register a custom URI handler.

Parameters
serverHandle to the HTTP server instance
uri_handlerPointer to the URI handler struct
Returns
ESP_OK on success, ESP_ERR_INVALID_ARG or other error codes on failure

Definition at line 278 of file web_server.c.

References LOGE, and LOGI.

◆ webserver_start()

httpd_handle_t webserver_start ( const webserver_config_t * config)

Initialize and start the HTTP web server.

This function creates a FreeRTOS task that manages the HTTP server. It serves static files from the data/ folder and supports dynamic handler registration.

Parameters
configConfiguration structure. If NULL, default values are used.
Returns
HTTP server handle on success, NULL on failure.

Initialize and start the HTTP web server.

Initializes storage, configures the HTTP server, registers default handlers, and starts the FreeRTOS task for async operation.

Parameters
configPointer to webserver configuration struct (optional)
Returns
Handle to the running HTTP server, or NULL on failure

Definition at line 166 of file web_server.c.

References health_check_handler(), LOGE, LOGI, LOGW, s_server_handle, s_server_task_handle, static_file_handler(), storage_init(), WEBSERVER_DEFAULT_MAX_HANDLERS, WEBSERVER_DEFAULT_PORT, WEBSERVER_DEFAULT_STACK_SIZE, WEBSERVER_DEFAULT_TASK_PRIORITY, and webserver_task().

Referenced by app_main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ webserver_stop()

void webserver_stop ( httpd_handle_t server)

Stop the web server and cleanup resources.

Parameters
serverHTTP server handle returned by webserver_start(). Safe to pass NULL.

Stop the web server and cleanup resources.

Stops the HTTP server and deletes the FreeRTOS task.

Parameters
serverHandle to the HTTP server instance

Definition at line 253 of file web_server.c.

References LOGI, s_server_handle, and s_server_task_handle.