pub trait RequestDefaults: RequestModifiers {
// Required methods
fn client(&self) -> &Client;
fn default_error_resolver<T>(&self) -> &dyn Fn(T);
// Provided methods
fn default_headers(&self, request_builder: RequestBuilder) -> RequestBuilder { ... }
fn default_parameters(
&self,
request_builder: RequestBuilder
) -> RequestBuilder { ... }
fn default_post_requestor(
&self,
endpoint: &str,
json: &str
) -> RequestBuilder { ... }
fn default_get_requestor<'a>(
&self,
endpoint: &str,
parameters: ParameterHashMap<'a>
) -> RequestBuilder { ... }
}
Expand description
The RequestDefaults trait provides a set of default methods for configuring and modifying HTTP requests.
Required Methods§
sourcefn client(&self) -> &Client
fn client(&self) -> &Client
Returns the reqwest::Client instance associated with the API client.
The client is used to send HTTP requests to the API.
Examples
fn main() {
let api_client = APIClient::new();
let client = api_client.client();
// Use the client to make HTTP requests
// ...
}
sourcefn default_error_resolver<T>(&self) -> &dyn Fn(T)
fn default_error_resolver<T>(&self) -> &dyn Fn(T)
This function is used to handle errors that occur during API requests and responses. The error resolver function takes an error of type T as input and returns a reference to a dynamic function that handles the error. The dynamic function can be customized to handle specific error types or perform specific error handling logic.
Note: The actual implementation of the error resolver function is not provided here, as it may vary depending on the specific use case and error type T.