pub trait AsyncAuthorizeRequest<B> {
    type RequestBody;
    type ResponseBody;

    // Required method
    async fn authorize(
        &mut self,
        request: Request<B>
    ) -> Result<Request<Self::RequestBody>, Response<Self::ResponseBody>>;
}
Available on crate feature auth only.
Expand description

Trait for authorizing requests.

Required Associated Types§

source

type RequestBody

The type of request body returned by authorize.

Set this to B unless you need to change the request body type.

source

type ResponseBody

The body type used for responses to unauthorized requests.

Required Methods§

source

async fn authorize( &mut self, request: Request<B> ) -> Result<Request<Self::RequestBody>, Response<Self::ResponseBody>>

Authorize the request.

If the future resolves to Ok(request) then the request is allowed through, otherwise not.

Implementors§

source§

impl<B, F, Fut, ReqBody, ResBody> AsyncAuthorizeRequest<B> for Fwhere F: FnMut(Request<B>) -> Fut, Fut: Future<Output = Result<Request<ReqBody>, Response<ResBody>>>,

§

type RequestBody = ReqBody

§

type ResponseBody = ResBody