diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 5b86a3977..1a7e5ed5b 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -1,5 +1,9 @@ # Changes +### Added + +* Add impl ResponseBuilder for Error + ## [1.0.0-alpha.3] - 2019-12-07 ### Changed diff --git a/actix-http/src/client/connector.rs b/actix-http/src/client/connector.rs index 02e9df7d1..c78597d01 100644 --- a/actix-http/src/client/connector.rs +++ b/actix-http/src/client/connector.rs @@ -87,9 +87,9 @@ impl Connector<(), ()> { let protos = vec![b"h2".to_vec(), b"http/1.1".to_vec()]; let mut config = ClientConfig::new(); config.set_protocols(&protos); - config.root_store.add_server_trust_anchors( - &actix_tls::rustls::TLS_SERVER_ROOTS, - ); + config + .root_store + .add_server_trust_anchors(&actix_tls::rustls::TLS_SERVER_ROOTS); SslConnector::Rustls(Arc::new(config)) } #[cfg(not(any(feature = "openssl", feature = "rustls")))] diff --git a/actix-http/src/error.rs b/actix-http/src/error.rs index c580f3846..ec56900fc 100644 --- a/actix-http/src/error.rs +++ b/actix-http/src/error.rs @@ -22,7 +22,7 @@ use serde_urlencoded::ser::Error as FormError; use crate::body::Body; pub use crate::cookie::ParseError as CookieParseError; use crate::helpers::Writer; -use crate::response::Response; +use crate::response::{Response, ResponseBuilder}; /// A specialized [`Result`](https://doc.rust-lang.org/std/result/enum.Result.html) /// for actix web operations @@ -157,6 +157,20 @@ impl From for Error { } } +/// Convert Response to a Error +impl From for Error { + fn from(res: Response) -> Error { + InternalError::from_response("", res).into() + } +} + +/// Convert ResponseBuilder to a Error +impl From for Error { + fn from(mut res: ResponseBuilder) -> Error { + InternalError::from_response("", res.finish()).into() + } +} + /// Return `GATEWAY_TIMEOUT` for `TimeoutError` impl ResponseError for TimeoutError { fn status_code(&self) -> StatusCode { @@ -555,13 +569,6 @@ where } } -/// Convert Response to a Error -impl From for Error { - fn from(res: Response) -> Error { - InternalError::from_response("", res).into() - } -} - /// Helper function that creates wrapper of any error and generate *BAD /// REQUEST* response. #[allow(non_snake_case)]