Skip to content

Commit 693a288

Browse files
committed
Update response extensions to match request methods
1 parent 9f3cde6 commit 693a288

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/response.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,15 @@ impl Response {
422422
self.res.ext().get()
423423
}
424424

425-
/// Set a response scoped extension value.
426-
pub fn insert_ext<T: Send + Sync + 'static>(&mut self, val: T) {
427-
self.res.ext_mut().insert(val);
425+
/// Get a mutable reference to value stored in response extensions.
426+
#[must_use]
427+
pub fn ext_mut<T: Send + Sync + 'static>(&mut self) -> Option<&mut T> {
428+
self.res.ext_mut().get_mut()
429+
}
430+
431+
/// Set a response extension value.
432+
pub fn set_ext<T: Send + Sync + 'static>(&mut self, val: T) -> Option<T> {
433+
self.res.ext_mut().insert(val)
428434
}
429435

430436
/// Create a `tide::Response` from a type that can be converted into an

0 commit comments

Comments
 (0)