From ded1e86e7eb0799b9a31401e00f50ab1206a2abe Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 22 May 2019 21:25:51 -0700 Subject: [PATCH] Add ServiceRequest::set_payload() method --- CHANGES.md | 2 ++ src/service.rs | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 16ac0d12..6cd109a0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,8 @@ ### Add +* Add `ServiceRequest::set_payload()` method. + * Add `test::TestRequest::set_json()` convenience method to automatically serialize data and set header in test requests. diff --git a/src/service.rs b/src/service.rs index f4f1a205..722813a9 100644 --- a/src/service.rs +++ b/src/service.rs @@ -189,6 +189,11 @@ impl ServiceRequest { } } + /// Set request payload. + pub fn set_payload(&mut self, payload: Payload) { + Rc::get_mut(&mut (self.0).0).unwrap().payload = payload; + } + #[doc(hidden)] /// Set new app data container pub fn set_data_container(&mut self, extensions: Rc) {