pub struct PermissionService<F, Args, P1, P1Args>where
F: Handler<Args>,
Args: FromRequest,
F::Output: Responder,
P1: Permission<P1Args>,
P1Args: FromRequest,{ /* private fields */ }Expand description
Service that intercepts a request and validates it with a permission.
If permission fails, deny_handler is called.
If permission succeeds, request is proxied to handler.
§Properties
handler- handler, a function that returns http (serializable) response.pd_handler- marker for handler type args, needed to avoid warnings of unusedArgs.deny_handler- function argument, called when permission check is false.permission- permissionpd_permission- marker for permission type args, needed to avoid warnings of unusedP1Args.ready- flag that tells if future incallis completed or pending.
Implementations§
Source§impl<F, Args, P1, P1Args> PermissionService<F, Args, P1, P1Args>where
F: Handler<Args>,
Args: FromRequest,
P1: Permission<P1Args>,
P1Args: FromRequest,
F::Output: Responder,
impl<F, Args, P1, P1Args> PermissionService<F, Args, P1, P1Args>where
F: Handler<Args>,
Args: FromRequest,
P1: Permission<P1Args>,
P1Args: FromRequest,
F::Output: Responder,
Sourcepub fn new(
permission: P1,
handler: F,
deny_handler: fn(HttpRequest) -> HttpResponse,
) -> Self
pub fn new( permission: P1, handler: F, deny_handler: fn(HttpRequest) -> HttpResponse, ) -> Self
Creates new PermissionService.
Trait Implementations§
Source§impl<F, Args, P1, P1Args> Service<ServiceRequest> for PermissionService<F, Args, P1, P1Args>where
F: Handler<Args>,
Args: FromRequest,
P1: Permission<P1Args>,
P1Args: FromRequest,
F::Output: Responder,
impl<F, Args, P1, P1Args> Service<ServiceRequest> for PermissionService<F, Args, P1, P1Args>where
F: Handler<Args>,
Args: FromRequest,
P1: Permission<P1Args>,
P1Args: FromRequest,
F::Output: Responder,
Source§type Response = ServiceResponse
type Response = ServiceResponse
Responses given by the service.
Source§type Error = Infallible
type Error = Infallible
Errors produced by the service when polling readiness or executing call.
Source§type Future = Pin<Box<dyn Future<Output = Result<<PermissionService<F, Args, P1, P1Args> as Service<ServiceRequest>>::Response, <PermissionService<F, Args, P1, P1Args> as Service<ServiceRequest>>::Error>>>>
type Future = Pin<Box<dyn Future<Output = Result<<PermissionService<F, Args, P1, P1Args> as Service<ServiceRequest>>::Response, <PermissionService<F, Args, P1, P1Args> as Service<ServiceRequest>>::Error>>>>
The future response value.
Auto Trait Implementations§
impl<F, Args, P1, P1Args> Freeze for PermissionService<F, Args, P1, P1Args>
impl<F, Args, P1, P1Args> RefUnwindSafe for PermissionService<F, Args, P1, P1Args>
impl<F, Args, P1, P1Args> Send for PermissionService<F, Args, P1, P1Args>
impl<F, Args, P1, P1Args> Sync for PermissionService<F, Args, P1, P1Args>
impl<F, Args, P1, P1Args> Unpin for PermissionService<F, Args, P1, P1Args>
impl<F, Args, P1, P1Args> UnwindSafe for PermissionService<F, Args, P1, P1Args>
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>
Source§impl<S, Req> IntoService<S, Req> for Swhere
S: Service<Req>,
impl<S, Req> IntoService<S, Req> for Swhere
S: Service<Req>,
Source§fn into_service(self) -> S
fn into_service(self) -> S
Convert to a
ServiceSource§impl<S, Req> ServiceExt<Req> for Swhere
S: Service<Req>,
impl<S, Req> ServiceExt<Req> for Swhere
S: Service<Req>,
Source§fn map<F, R>(self, f: F) -> Map<Self, F, Req, R>
fn map<F, R>(self, f: F) -> Map<Self, F, Req, R>
Map this service’s output to a different type, returning a new service
of the resulting type. Read more