Struct esp32_simple::http::Client
source · pub struct Client<'a> { /* private fields */ }Expand description
Represents an HTTP client that interacts with a server over Wi-Fi.
This struct provides methods to send HTTP requests, such as POST requests, using the ESP-IDF framework. It owns an active Wi-Fi connection for the duration of its lifetime.
Implementations§
source§impl<'a> Client<'a>
impl<'a> Client<'a>
sourcepub fn new(wifi: Connection<'a>) -> Result<Self>
pub fn new(wifi: Connection<'a>) -> Result<Self>
sourcepub fn post(&mut self, url: &str, payload: Option<&[u8]>) -> Result<u16>
pub fn post(&mut self, url: &str, payload: Option<&[u8]>) -> Result<u16>
Sends a POST request to the specified URL with an optional payload.
§Arguments
url- The URL to send the POST request to.payload- An optional byte slice containing the payload to send.
§Returns
The HTTP status code of the response.
§Errors
Returns an error if the Wi-Fi is not connected, the request fails, or the response status is not in the success range.