5 releases
Uses old Rust 2015
0.0.5 | Aug 30, 2017 |
---|---|
0.0.4 | Jul 17, 2017 |
0.0.3 | Jul 16, 2017 |
0.0.2 | Jul 16, 2017 |
0.0.1 | Jul 16, 2017 |
#84 in #https
120KB
1.5K
SLoC
simplist: plain and simple http.
a plain and simple http library for when you just want to make a darn request!
this crate is a super thin and lightweight wrapper on top of hyper, and provides apis for futures-based async, traditional sync and async-await models.
HttpClient
is the primary interface for making http requests.
features.
nightly
: when turned on, simplist will perform about one allocation per request by usingimpl Future
, which is currently an experimental feature. when compiling for the stable compiler, simplist needs to box some future types because they cannot be named.scramble
: when turned on, simplist will compile out most error messages, replacing them with an empty string.
if you're using a nightly compiler, turn on the nightly feature in your cargo.toml
!
simplist = { version = "0.0.5", features = ["nightly"] }
examples.
asynchronous, with await notation.
use simplist::HttpClient;
let http = HttpClient::new(handle);
let html = await http.get_string("https://hinaria.com")?;
println!("{:?}", html);
// => "<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\"> ..."
asynchronous, with future callbacks.
use simplist::HttpClient;
let http = HttpClient::new(handle);
let future = http.get_string("https://hinaria.com").and_then(|html| {
println!("{:?}", html);
Ok(())
}).map_err(|_| ());
handle.spawn(future);
// => "<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\"> ..."
synchronous.
use simplist::HttpSyncClient;
let http = HttpSyncClient::new(handle);
let html = http.get_string("https://hinaria.com")?;
println!("{:?}", html);
// => "<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\"> ..."
Dependencies
~9MB
~148K SLoC