From 2e9bac7f0f5609611c12b40e9bd195d8f2e121d3 Mon Sep 17 00:00:00 2001 From: Fangdun Tsai Date: Thu, 29 Sep 2022 09:46:50 +0800 Subject: [PATCH] chore(core): get a limits ref --- viz-core/src/request.rs | 5 ++--- viz-core/src/types/limits.rs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/viz-core/src/request.rs b/viz-core/src/request.rs index 4cd3891e..4204b6d2 100644 --- a/viz-core/src/request.rs +++ b/viz-core/src/request.rs @@ -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. @@ -325,10 +325,9 @@ impl RequestExt for Request { } #[cfg(feature = "limits")] - fn limits(&self) -> Limits { + fn limits(&self) -> &Limits { self.extensions() .get::() - .cloned() .expect("Limits middleware is required") } diff --git a/viz-core/src/types/limits.rs b/viz-core/src/types/limits.rs index 66201831..d75907ad 100644 --- a/viz-core/src/types/limits.rs +++ b/viz-core/src/types/limits.rs @@ -68,6 +68,6 @@ impl FromRequest for Limits { type Error = Infallible; async fn extract(req: &mut Request) -> Result { - Ok(req.limits()) + Ok(req.limits().clone()) } }