pub unsafe extern "C" fn httpd_register_uri_handler(
    handle: httpd_handle_t,
    uri_handler: *const httpd_uri_t
) -> esp_err_t
Expand description

@brief Registers a URI handler

@note URI handlers can be registered in real time as long as the server handle is valid.

Example usage: @code{c}

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 …. }

@endcode

@param[in] handle handle to HTTPD server instance @param[in] uri_handler pointer to handler that needs to be registered

@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 registered