Crates.io | weblib |
lib.rs | weblib |
version | 0.1.4 |
source | src |
created_at | 2023-05-09 01:43:53.524453 |
updated_at | 2023-05-16 16:15:55.911296 |
description | The Rust weblib Library is a small, simple library for fetching the contents of a URL and returning them as a string. |
homepage | https://github.com/mac-lawson/web |
repository | |
max_upload_size | |
id | 860191 |
size | 75,372 |
weblib
LibraryThe Rust weblib
Library is a small, simple library for fetching the contents of a URL and returning them as a string.
You can add this library as a dependency to your Rust project by adding the following line to your Cargo.toml file:
[dependencies]
weblib = "0.1.4"
Here is an example of how to use the text
function:
let url = "https://httpbin.org/ip";
match weblib::text(url) {
Ok(resp) => println!("{}", resp),
Err(e) => panic!("Error: {}", e),
}
Here is an example of how to use the query
function:
let url = "https://httpbin.org/get";
let query_string = "key1=value1&key2=value2";
match weblib::query(url, query_string) {
Ok(resp) => println!("{}", resp),
Err(e) => panic!("Error: {}", e),
}
Here is an example of how to use the post
function:
let url = "https://httpbin.org/post";
let data = "key1=value1&key2=value2";
match weblib::post(url, data) {
Ok(resp) => println!("{}", resp),
Err(e) => panic!("Error: {}", e),
}
Tests can be run with the following command:
cargo test
This library was created by Mac Lawson.
This library is licensed under the GPLv3. See the LICENSE file for details.