pub trait Endpoint<T> {
type Output;
type Error: Into<Error>;
type Future: TryFuture<Ok = Self::Output, Error = Self::Error>;
fn apply(
&self,
args: T,
cx: &mut ApplyContext<'_, '_>
) -> ApplyResult<T, Self>;
fn allowed_methods(&self) -> Option<AllowedMethods>;
}
Expand description
A trait representing the process to be performed when a route matches.
Required Associated Types
type Output
type Error: Into<Error>
type Future: TryFuture<Ok = Self::Output, Error = Self::Error>
Required Methods
sourcefn apply(&self, args: T, cx: &mut ApplyContext<'_, '_>) -> ApplyResult<T, Self>
fn apply(&self, args: T, cx: &mut ApplyContext<'_, '_>) -> ApplyResult<T, Self>
Determines the Action
that this endpoint performs based on the request method.
If the endpoint does not accept the incoming request method, it returns an Err
.
sourcefn allowed_methods(&self) -> Option<AllowedMethods>
fn allowed_methods(&self) -> Option<AllowedMethods>
Returns a list of HTTP methods that this endpoint accepts.
If it returns a None
, it means that the endpoint accepts all methods.
This method is called when constructing a Handler
and used for implementation of
Handler::allowed_methods
.