Espressif ESP32-S2 Programming Manual page 585

Table of Contents

Advertisement

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
Registers a URI handler.
Example usage:
esp_err_t
my_uri_handler(httpd_req_t*
{
// Recv , Process and Send
....
....
....
// Fail condition
if
(....) {
// Return fail to close session //
return
}
// On success
return
ESP_OK;
}
// URI handler structure
httpd_uri_t my_uri {
.uri
=
.method
=
.handler
=
.user_ctx
=
};
// Register handler
if
(httpd_register_uri_handler(server_handle, &my_uri)
// 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
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
ESP_FAIL;
"/my_uri/path/xyz",
HTTPD_GET,
my_uri_handler,
NULL
Submit Document Feedback
handle, const
req)
handle,
httpd_method_t
method)
574
httpd_uri_t
*uri_handler)
!=
ESP_OK) {
const
char
*uri,
Release v4.4

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32-S2 and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Table of Contents

Save PDF