Skip to content

Commit

Permalink
Update response extensions to match request methods
Browse files Browse the repository at this point in the history
  • Loading branch information
nyxtom committed Jul 21, 2022
1 parent 9f3cde6 commit 693a288
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,15 @@ impl Response {
self.res.ext().get()
}

/// Set a response scoped extension value.
pub fn insert_ext<T: Send + Sync + 'static>(&mut self, val: T) {
self.res.ext_mut().insert(val);
/// Get a mutable reference to value stored in response extensions.
#[must_use]
pub fn ext_mut<T: Send + Sync + 'static>(&mut self) -> Option<&mut T> {
self.res.ext_mut().get_mut()
}

/// Set a response extension value.
pub fn set_ext<T: Send + Sync + 'static>(&mut self, val: T) -> Option<T> {
self.res.ext_mut().insert(val)
}

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

0 comments on commit 693a288

Please sign in to comment.