1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
mod httpclient;
pub use httpclient::*;
impl Default for HttpRequest {
fn default() -> HttpRequest {
HttpRequest {
method: "GET".to_string(),
url: String::default(),
headers: HeaderMap::default(),
body: Vec::default(),
}
}
}
impl HttpRequest {
pub fn get(url: &str) -> HttpRequest {
HttpRequest {
url: url.to_string(),
..Default::default()
}
}
pub fn post(url: &str, body: Vec<u8>) -> HttpRequest {
HttpRequest {
method: "POST".to_string(),
url: url.to_string(),
body,
..Default::default()
}
}
pub fn put(url: &str, body: Vec<u8>) -> HttpRequest {
HttpRequest {
method: "PUT".to_string(),
url: url.to_string(),
body,
..Default::default()
}
}
}
impl Default for HttpResponse {
fn default() -> HttpResponse {
HttpResponse {
status_code: 200,
header: HeaderMap::default(),
body: Vec::default(),
}
}
}