2018-02-19 22:18:18 +01:00
|
|
|
//! Http client
|
2018-01-30 22:04:52 +01:00
|
|
|
mod connector;
|
2018-01-28 07:03:03 +01:00
|
|
|
mod parser;
|
2018-01-29 20:39:26 +01:00
|
|
|
mod request;
|
2018-01-28 07:03:03 +01:00
|
|
|
mod response;
|
2018-02-19 12:11:11 +01:00
|
|
|
mod pipeline;
|
2018-01-29 23:44:25 +01:00
|
|
|
mod writer;
|
2018-01-28 07:03:03 +01:00
|
|
|
|
2018-02-19 12:11:11 +01:00
|
|
|
pub use self::pipeline::{SendRequest, SendRequestError};
|
2018-01-29 20:39:26 +01:00
|
|
|
pub use self::request::{ClientRequest, ClientRequestBuilder};
|
2018-02-28 00:03:28 +01:00
|
|
|
pub use self::response::ClientResponse;
|
2018-01-30 22:04:52 +01:00
|
|
|
pub use self::connector::{Connect, Connection, ClientConnector, ClientConnectorError};
|
2018-02-19 12:11:11 +01:00
|
|
|
pub(crate) use self::writer::HttpClientWriter;
|
|
|
|
pub(crate) use self::parser::{HttpResponseParser, HttpResponseParserError};
|
2018-03-05 22:02:31 +01:00
|
|
|
|
|
|
|
use error::ResponseError;
|
2018-03-31 08:07:33 +02:00
|
|
|
use httpresponse::HttpResponse;
|
2018-03-05 22:02:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
/// Convert `SendRequestError` to a `HttpResponse`
|
|
|
|
impl ResponseError for SendRequestError {
|
|
|
|
|
|
|
|
fn error_response(&self) -> HttpResponse {
|
|
|
|
match *self {
|
2018-03-31 08:07:33 +02:00
|
|
|
SendRequestError::Connector(_) => HttpResponse::BadGateway(),
|
|
|
|
_ => HttpResponse::InternalServerError(),
|
2018-03-05 22:02:31 +01:00
|
|
|
}
|
2018-03-31 08:07:33 +02:00
|
|
|
.into()
|
2018-03-05 22:02:31 +01:00
|
|
|
}
|
|
|
|
}
|