diff --git a/src/lib.rs b/src/lib.rs index 4e6e37955..8750b24ca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -89,12 +89,11 @@ pub mod h2; pub mod test; pub mod ws; -pub use self::body::{Body, MessageBody}; pub use self::config::{KeepAlive, ServiceConfig, ServiceConfigBuilder}; pub use self::error::{Error, ResponseError, Result}; pub use self::extensions::Extensions; pub use self::httpmessage::HttpMessage; -pub use self::message::{Message, RequestHead, ResponseHead}; +pub use self::message::{Head, Message, RequestHead, ResponseHead}; pub use self::payload::{Payload, PayloadStream}; pub use self::request::Request; pub use self::response::Response; diff --git a/src/response.rs b/src/response.rs index d84100fa2..0295758b2 100644 --- a/src/response.rs +++ b/src/response.rs @@ -242,6 +242,20 @@ impl Response { self.body, ) } + + /// Set a body and return previous body value + pub fn map_body(mut self, f: F) -> Response + where + F: FnOnce(&mut ResponseHead, ResponseBody) -> ResponseBody, + { + let body = f(&mut self.head, self.body); + + Response { + head: self.head, + body: body, + error: self.error, + } + } } impl fmt::Debug for Response {