EasyManua.ls Logo

Espressif ESP32-S2 - Page 585

Espressif ESP32-S2
1695 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 2. API Reference
API Reference
Header File
• components/esp_http_server/include/esp_http_server.h
Functions
esp_err_t httpd_register_uri_handler(httpd_handle_t handle, const httpd_uri_t *uri_handler)
Registers a URI handler.
Example usage:
esp_err_t my_uri_handler(httpd_req_t* req)
{
// Recv , Process and Send
....
....
....
// Fail condition
if (....) {
// Return fail to close session //
return ESP_FAIL;
}
// On success
return ESP_OK;
}
// URI handler structure
httpd_uri_t my_uri {
.uri = "/my_uri/path/xyz",
.method = HTTPD_GET,
.handler = my_uri_handler,
.user_ctx = NULL
};
// Register handler
if (httpd_register_uri_handler(server_handle, &my_uri) != ESP_OK) {
// If failed to register handler
....
}
Note URI handlers can be registered in real time as long as the server handle is valid.
Return
• ESP_OK : On successfully registering the handler
• ESP_ERR_INVALID_ARG : Null arguments
• ESP_ERR_HTTPD_HANDLERS_FULL : If no slots left for new handler
• ESP_ERR_HTTPD_HANDLER_EXISTS : If handler with same URI and method is already reg-
istered
Parameters
• [in] handle: handle to HTTPD server instance
• [in] uri_handler: pointer to handler that needs to be registered
esp_err_t httpd_unregister_uri_handler(httpd_handle_t handle, const char *uri,
httpd_method_t method)
Unregister a URI handler.
Return
• ESP_OK : On successfully deregistering the handler
• ESP_ERR_INVALID_ARG : Null arguments
• ESP_ERR_NOT_FOUND : Handler with specified URI and method not found
Espressif Systems 574
Submit Document Feedback
Release v4.4

Table of Contents