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) {