rama_http::layer::auth

Trait AsyncAuthorizeRequest

Source
pub trait AsyncAuthorizeRequest<S, B> {
    type RequestBody;
    type ResponseBody;

    // Required method
    fn authorize(
        &self,
        ctx: Context<S>,
        request: Request<B>,
    ) -> impl Future<Output = Result<(Context<S>, Request<Self::RequestBody>), Response<Self::ResponseBody>>> + Send + '_;
}
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

fn authorize( &self, ctx: Context<S>, request: Request<B>, ) -> impl Future<Output = Result<(Context<S>, Request<Self::RequestBody>), Response<Self::ResponseBody>>> + Send + '_

Authorize the request.

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<S, B, F, Fut, ReqBody, ResBody> AsyncAuthorizeRequest<S, B> for F
where F: Fn(Context<S>, Request<B>) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<(Context<S>, Request<ReqBody>), Response<ResBody>>> + Send + 'static, B: Send + 'static, S: Clone + Send + Sync + 'static, ReqBody: Send + 'static, ResBody: Send + 'static,

Source§

type RequestBody = ReqBody

Source§

type ResponseBody = ResBody