Skip to content

Commit

Permalink
chore(core): get a limits ref
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Sep 29, 2022
1 parent 57121e4 commit 2e9bac7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions viz-core/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub trait RequestExt: Sized {

#[cfg(feature = "limits")]
/// Get limits settings.
fn limits(&self) -> Limits;
fn limits(&self) -> &Limits;

#[cfg(feature = "session")]
/// Get current session.
Expand Down Expand Up @@ -325,10 +325,9 @@ impl RequestExt for Request<Body> {
}

#[cfg(feature = "limits")]
fn limits(&self) -> Limits {
fn limits(&self) -> &Limits {
self.extensions()
.get::<Limits>()
.cloned()
.expect("Limits middleware is required")
}

Expand Down
2 changes: 1 addition & 1 deletion viz-core/src/types/limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ impl FromRequest for Limits {
type Error = Infallible;

async fn extract(req: &mut Request) -> Result<Self, Self::Error> {
Ok(req.limits())
Ok(req.limits().clone())
}
}

0 comments on commit 2e9bac7

Please sign in to comment.