tower_http::auth

Trait AsyncAuthorizeRequest

Source
pub trait AsyncAuthorizeRequest<B> {
    type RequestBody;
    type ResponseBody;
    type Future: Future<Output = Result<Request<Self::RequestBody>, Response<Self::ResponseBody>>>;

    // Required method
    fn authorize(&mut self, request: Request<B>) -> Self::Future;
}
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.

Source

type Future: Future<Output = Result<Request<Self::RequestBody>, Response<Self::ResponseBody>>>

The Future type returned by authorize

Required Methods§

Source

fn authorize(&mut self, request: Request<B>) -> Self::Future

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 F
where F: FnMut(Request<B>) -> Fut, Fut: Future<Output = Result<Request<ReqBody>, Response<ResBody>>>,

Source§

type RequestBody = ReqBody

Source§

type ResponseBody = ResBody

Source§

type Future = Fut