You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
524 B
19 lines
524 B
7 years ago
|
use Result;
|
||
|
use reqwest::{Client, Request, RequestBuilder, Response};
|
||
|
|
||
|
pub trait HttpSend {
|
||
|
fn execute(&self, client: &Client, request: Request) -> Result<Response>;
|
||
|
fn send(&self, client: &Client, builder: &mut RequestBuilder) -> Result<Response> {
|
||
|
let request = builder.build()?;
|
||
|
self.execute(client, request)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub struct HttpSender;
|
||
|
|
||
|
impl HttpSend for HttpSender {
|
||
|
fn execute(&self, client: &Client, request: Request) -> Result<Response> {
|
||
|
Ok(client.execute(request)?)
|
||
|
}
|
||
|
}
|