mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-28 01:32:57 +01:00
allow to extract body from response
This commit is contained in:
parent
d85468f7e1
commit
34c8b95a35
@ -59,6 +59,12 @@ impl ResponseBody<Body> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<B> ResponseBody<B> {
|
||||
pub fn take_body(&mut self) -> ResponseBody<B> {
|
||||
std::mem::replace(self, ResponseBody::Other(Body::None))
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: MessageBody> ResponseBody<B> {
|
||||
pub fn as_ref(&self) -> Option<&B> {
|
||||
if let ResponseBody::Body(ref b) = self {
|
||||
|
@ -254,6 +254,11 @@ impl<B> Response<B> {
|
||||
error: self.error,
|
||||
}
|
||||
}
|
||||
|
||||
/// Extract response body
|
||||
pub fn take_body(&mut self) -> ResponseBody<B> {
|
||||
self.body.take_body()
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: MessageBody> fmt::Debug for Response<B> {
|
||||
|
Loading…
Reference in New Issue
Block a user