#http-request #http #web #url #string #content #post

bin+lib weblib

The Rust weblib Library is a small, simple library for fetching the contents of a URL and returning them as a string

5 releases

0.1.4 May 16, 2023
0.1.3 May 10, 2023
0.1.2 May 10, 2023
0.1.1 May 9, 2023
0.1.0 May 9, 2023

#288 in HTTP client

Download history 4/week @ 2024-02-25 1/week @ 2024-03-10 65/week @ 2024-03-31

66 downloads per month

GPL-3.0 license

24KB
115 lines

Rust weblib Library

The Rust weblib Library is a small, simple library for fetching the contents of a URL and returning them as a string.
GitHubGitHub commit activity

Installation:

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"

Usage:

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),
  }

Running tests:

Tests can be run with the following command:

cargo test

Author

This library was created by Mac Lawson.

License

This library is licensed under the GPLv3. See the LICENSE file for details.

Dependencies

~3–17MB
~233K SLoC