Endpoint

Trait Endpoint 

Source
pub trait Endpoint:
    Send
    + Sync
    + 'static {
    // Required method
    fn apply<'life0, 'async_trait>(
        self: Pin<&'life0 Self>,
        request: Request,
    ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

An HTTP request handler.

This is automatically implemented for Fn(Request) -> impl Future<Output = impl IntoResponse> types, but it may be useful to implement this yourself. All this is meant to do is be a fallible function from a Request into a Response.

Required Methods§

Source

fn apply<'life0, 'async_trait>( self: Pin<&'life0 Self>, request: Request, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Transforms the request into the response. However, a request may fail, and such a failure can be handled by down the stack.

Trait Implementations§

Source§

impl Debug for dyn Endpoint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Implementors§

Source§

impl Endpoint for ScopeEndpoint

Source§

impl Endpoint for Router

Source§

impl<F, Fut> Endpoint for SseEndpoint<F>
where F: Fn(Request, Sender) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<()>> + Send + 'static,

Available on crate feature sse only.
Source§

impl<Res, F, Fut> Endpoint for F
where F: Fn(Request) -> Fut + Sync + Send + 'static, Fut: Future<Output = Res> + Send + 'static, Res: IntoResponse + Send + 'static,