Trait Endpoint

Source
pub trait Endpoint {
    type Output: IntoResponse + Send;
    type Placeholders: PathExtractor<Body> + Clone + Sync;
    type Params: QueryStringExtractor<Body> + Clone + Sync;
    type Body: RequestBody + Send;

    // Required methods
    fn http_method() -> Method;
    fn uri() -> Cow<'static, str>;
    fn handle(
        state: &mut State,
        placeholders: Self::Placeholders,
        params: Self::Params,
        body: Option<Self::Body>,
    ) -> BoxFuture<'_, Self::Output>;

    // Provided methods
    fn has_placeholders() -> bool { ... }
    fn needs_params() -> bool { ... }
    fn needs_body() -> bool { ... }
    fn wants_auth() -> bool { ... }
}

Required Associated Types§

Source

type Output: IntoResponse + Send

The output type that provides the response.

Source

type Placeholders: PathExtractor<Body> + Clone + Sync

The type that parses the URI placeholders. Use NoopExtractor if has_placeholders() returns false.

Source

type Params: QueryStringExtractor<Body> + Clone + Sync

The type that parses the request parameters. Use NoopExtractor if needs_params() returns false.

Source

type Body: RequestBody + Send

The type to parse the body into. Use () if needs_body() returns false.

Required Methods§

Source

fn http_method() -> Method

The HTTP Verb of this endpoint.

Source

fn uri() -> Cow<'static, str>

The URI that this endpoint listens on in gotham’s format.

Source

fn handle( state: &mut State, placeholders: Self::Placeholders, params: Self::Params, body: Option<Self::Body>, ) -> BoxFuture<'_, Self::Output>

The handler for this endpoint.

Provided Methods§

Source

fn has_placeholders() -> bool

Returns true iff the URI contains placeholders. false by default.

Source

fn needs_params() -> bool

Returns true iff the request parameters should be parsed. false by default.

Source

fn needs_body() -> bool

Returns true iff the request body should be parsed. false by default.

Source

fn wants_auth() -> bool

Returns true if the request wants to know the auth status of the client. false by default.

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§