Building HTTP requests

We will start our project by creating the ESP32 project, called webserver, with webserver.c as the main program. You can initialize the Wi-Fi service on the ESP32 that we have learned. For a web server with ESP32 API information, we can read the official document at https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/protocols/esp_http_server.html.

To build a HTTP request, we will use the httpd_uri_t struct. We can declare the uri_get variable as the httpd_uri_t struct as follows:

httpd_uri_t uri_get = {    .uri = "/uri",    .method = HTTP_GET,    .handler = get_handler,    .user_ctx = NULL};

httpd_uri_t.method can be HTTP_GET, HTTP_POST, and HTTP_PUT. We pass our function on httpd_uri_t.handler to process a HTTP ...

Get Internet of Things Projects with ESP32 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.