Crates.io | knock |
lib.rs | knock |
version | 0.1.8 |
source | src |
created_at | 2017-04-14 18:27:32.365732 |
updated_at | 2018-08-13 07:17:59.250476 |
description | Knock is a simple HTTP Client for Rust |
homepage | https://github.com/nsheremet/knock |
repository | https://github.com/nsheremet/knock |
max_upload_size | |
id | 10599 |
size | 43,318 |
Knock is a simple HTTP Client for Rust
# Cargo.toml
[dependencies]
knock = "0.1"
An example client looks like:
extern crate knock;
use knock::HTTP;
fn main() {
let http = HTTP::new("https://google.com").unwrap();
let response = http.get().send();
}
For sending POST requests with custom headers
extern crate knock;
use knock::HTTP;
use std::collections::HashMap;
fn main() {
let http = HTTP::new("https://google.com").unwrap();
let mut body = HashMap::new();
let mut headers = HashMap::new();
body.insert("file", Data::File("/path/to/file.file"));
body.insert("field", Data::String("value"));
headers.insert("Content-Type", "multipart/form-data");
let response = http.post().body(body).header(headers).send();
}
knock
is primarily distributed under the terms of Mozilla Public License 2.0.
See LICENSE for details.