Crates.io | rust-fetch |
lib.rs | rust-fetch |
version | 0.1.0 |
source | src |
created_at | 2024-05-03 13:35:49.065039 |
updated_at | 2024-05-03 13:35:49.065039 |
description | An easy to use reqwest wrapper |
homepage | |
repository | |
max_upload_size | |
id | 1228776 |
size | 44,765 |
Rust Fetch is an easy-to-use HTTP client for making web requests in Rust applications. It provides a simple and minimalistic interface for sending HTTP requests, handling responses, and managing request options.
Easy-to-use API for sending POST, GET, DELETE, PUT, and PATCH requests
Serialization and deserialization support for JSON, XML, and URL-encoded data
Customizable request headers and query parameters
Error handling for network errors, deserialization errors, and fetch errors
Configurable request timeout and default headers
Add the following to your Cargo.toml
file:
[dependencies]
rust_fetch = "0.1.0"
basic example:
use rust_fetch::Fetch;
#[tokio::main]
async fn main() {
let client = Fetch::new("http://localhost", None).unwrap();
let response = client.post::<ToReturn, ToSend>(
"/test",
Some(ToSend {
test_key: "Testing".to_string(),
}),
Some(rust_fetch::FetchOptions {
params: Some(rust_fetch::map_string! { param1 : "value1" }),
..Default::default(),
}),
).await.unwrap();
assert_eq!(&200, &response.status);
assert_eq!(ToReturn {}, response.body.unwrap());
}
Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to submit a pull request or open an issue on the GitHub repository.
This library is licensed under the MIT License. See the LICENSE file for more details.
Feel free to customize and enhance this README template to better suit the features and usage of your Rust Fetch library.