Struct actix_governor::GovernorMiddleware
source · pub struct GovernorMiddleware<S, K: KeyExtractor, M: RateLimitingMiddleware<QuantaInstant>> { /* private fields */ }
Expand description
A middleware that implements rate limiting based on the governor crate.
Trait Implementations§
source§impl<S, B, K> Service<ServiceRequest> for GovernorMiddleware<S, K, NoOpMiddleware>where
K: KeyExtractor,
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
B: MessageBody,
impl<S, B, K> Service<ServiceRequest> for GovernorMiddleware<S, K, NoOpMiddleware>where K: KeyExtractor, S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>, B: MessageBody,
§type Response = ServiceResponse<EitherBody<B>>
type Response = ServiceResponse<EitherBody<B>>
Responses given by the service.
§type Error = <S as Service<ServiceRequest>>::Error
type Error = <S as Service<ServiceRequest>>::Error
Errors produced by the service when polling readiness or executing call.
§type Future = Either<MapOk<<S as Service<ServiceRequest>>::Future, fn(_: ServiceResponse<B>) -> ServiceResponse<EitherBody<B>>>, Ready<Result<ServiceResponse<EitherBody<B>>, <GovernorMiddleware<S, K, NoOpMiddleware> as Service<ServiceRequest>>::Error>>>
type Future = Either<MapOk<<S as Service<ServiceRequest>>::Future, fn(_: ServiceResponse<B>) -> ServiceResponse<EitherBody<B>>>, Ready<Result<ServiceResponse<EitherBody<B>>, <GovernorMiddleware<S, K, NoOpMiddleware> as Service<ServiceRequest>>::Error>>>
The future response value.
source§fn poll_ready(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn poll_ready(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
Returns
Ready
when the service is able to process requests. Read moresource§fn call(&self, req: ServiceRequest) -> Self::Future
fn call(&self, req: ServiceRequest) -> Self::Future
Process the request and return the response asynchronously. Read more
source§impl<S, B, K> Service<ServiceRequest> for GovernorMiddleware<S, K, StateInformationMiddleware>where
K: KeyExtractor,
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
B: MessageBody,
S::Future: Unpin,
impl<S, B, K> Service<ServiceRequest> for GovernorMiddleware<S, K, StateInformationMiddleware>where K: KeyExtractor, S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>, B: MessageBody, S::Future: Unpin,
Implementation using rate limit headers
§type Response = ServiceResponse<EitherBody<B>>
type Response = ServiceResponse<EitherBody<B>>
Responses given by the service.
§type Error = <S as Service<ServiceRequest>>::Error
type Error = <S as Service<ServiceRequest>>::Error
Errors produced by the service when polling readiness or executing call.
§type Future = Either<Either<Either<RateLimitHeaderFut<MapOk<<S as Service<ServiceRequest>>::Future, fn(_: ServiceResponse<B>) -> ServiceResponse<EitherBody<B>>>>, WhitelistedHeaderFut<MapOk<<S as Service<ServiceRequest>>::Future, fn(_: ServiceResponse<B>) -> ServiceResponse<EitherBody<B>>>>>, Ready<Result<ServiceResponse<EitherBody<B>>, Error>>>, MapOk<<S as Service<ServiceRequest>>::Future, fn(_: ServiceResponse<B>) -> ServiceResponse<EitherBody<B>>>>
type Future = Either<Either<Either<RateLimitHeaderFut<MapOk<<S as Service<ServiceRequest>>::Future, fn(_: ServiceResponse<B>) -> ServiceResponse<EitherBody<B>>>>, WhitelistedHeaderFut<MapOk<<S as Service<ServiceRequest>>::Future, fn(_: ServiceResponse<B>) -> ServiceResponse<EitherBody<B>>>>>, Ready<Result<ServiceResponse<EitherBody<B>>, Error>>>, MapOk<<S as Service<ServiceRequest>>::Future, fn(_: ServiceResponse<B>) -> ServiceResponse<EitherBody<B>>>>
The future response value.
source§fn poll_ready(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn poll_ready(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
Returns
Ready
when the service is able to process requests. Read moresource§fn call(&self, req: ServiceRequest) -> Self::Future
fn call(&self, req: ServiceRequest) -> Self::Future
Process the request and return the response asynchronously. Read more
Auto Trait Implementations§
impl<S, K, M> !RefUnwindSafe for GovernorMiddleware<S, K, M>
impl<S, K, M> !Send for GovernorMiddleware<S, K, M>
impl<S, K, M> !Sync for GovernorMiddleware<S, K, M>
impl<S, K, M> Unpin for GovernorMiddleware<S, K, M>where K: Unpin,
impl<S, K, M> !UnwindSafe for GovernorMiddleware<S, K, M>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<S, Req> IntoService<S, Req> for Swhere
S: Service<Req>,
impl<S, Req> IntoService<S, Req> for Swhere S: Service<Req>,
§fn into_service(self) -> S
fn into_service(self) -> S
Convert to a
Service
§impl<S, Req> ServiceExt<Req> for Swhere
S: Service<Req>,
impl<S, Req> ServiceExt<Req> for Swhere S: Service<Req>,
§fn map<F, R>(self, f: F) -> Map<Self, F, Req, R>where
Self: Sized,
F: FnMut(Self::Response) -> R,
fn map<F, R>(self, f: F) -> Map<Self, F, Req, R>where Self: Sized, F: FnMut(Self::Response) -> R,
Map this service’s output to a different type, returning a new service
of the resulting type. Read more