neo3/neo_types/url_session.rs
1use reqwest::{Client, Request};
2
3// Create a URLSession struct to manage HTTP requests
4pub struct URLSession;
5
6impl URLSession {
7 // Make an async method to send a request and return the response body bytes
8 pub async fn data(&self, request: Request) -> Result<Vec<u8>, reqwest::Error> {
9 // Create a reqwest client
10 let client = Client::new();
11
12 // Send the request and await the response
13 let response = client.execute(request).await?;
14
15 // Get the response bytes
16 let data = response.bytes().await?.to_vec();
17
18 // Return the data or any errors
19 Ok(data)
20 }
21}