Skip to content
This repository has been archived by the owner on Nov 2, 2019. It is now read-only.

Commit

Permalink
Rename cookies::CookiesExt to ContextExt
Browse files Browse the repository at this point in the history
As discussed in http-rs#187, context extension traits should have an import
path that explains their functionality, while being named after the
traits they extend.

Signed-off-by: Nicholas Young <nyoung@uptime.ventures>
  • Loading branch information
Nicholas Young committed May 13, 2019
1 parent 75b03d5 commit ec5a951
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/cookies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl CookieData {
}

/// An extension to `Context` that provides cached access to cookies
pub trait CookiesExt {
pub trait ContextExt {
/// returns a `Cookie` by name of the cookie
fn get_cookie(&mut self, name: &str) -> Result<Option<Cookie<'static>>, StringError>;

Expand All @@ -40,7 +40,7 @@ pub trait CookiesExt {
fn remove_cookie(&mut self, cookie: Cookie<'static>) -> Result<(), StringError>;
}

impl<State> CookiesExt for Context<State> {
impl<State> ContextExt for Context<State> {
fn get_cookie(&mut self, name: &str) -> Result<Option<Cookie<'static>>, StringError> {
let cookie_data = self
.extensions()
Expand Down
4 changes: 2 additions & 2 deletions src/middleware/cookies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{

/// Middleware to work with cookies.
///
/// [`CookiesMiddleware`] along with [`CookiesExt`](crate::cookies::CookiesExt) provide smooth
/// [`CookiesMiddleware`] along with [`ContextExt`](crate::cookies::ContextExt) provide smooth
/// access to request cookies and setting/removing cookies from response. This leverages the
/// [cookie](https://crates.io/crates/cookie) crate.
/// This middleware parses cookies from request and caches them in the extension. Once the request
Expand Down Expand Up @@ -63,7 +63,7 @@ impl<Data: Send + Sync + 'static> Middleware<Data> for CookiesMiddleware {
#[cfg(test)]
mod tests {
use super::*;
use crate::{cookies::CookiesExt, Context};
use crate::{cookies::ContextExt, Context};
use cookie::Cookie;
use futures::executor::block_on;
use http_service::Body;
Expand Down

0 comments on commit ec5a951

Please sign in to comment.