CreateRouteNode

Trait CreateRouteNode 

Source
pub trait CreateRouteNode: Sized {
    // Required methods
    fn at<H, T, R>(self, handler: H) -> RouteNode
       where H: Handler<T, R>,
             T: Extractor,
             R: Responder;
    fn post<H, T, R>(self, handler: H) -> RouteNode
       where H: Handler<T, R>,
             T: Extractor,
             R: Responder;
    fn put<H, T, R>(self, handler: H) -> RouteNode
       where H: Handler<T, R>,
             T: Extractor,
             R: Responder;
    fn delete<H, T, R>(self, handler: H) -> RouteNode
       where H: Handler<T, R>,
             T: Extractor,
             R: Responder;
    fn route(self, routes: impl Routes) -> RouteNode;
    fn endpoint<E>(self, method: Method, endpoint: E) -> RouteNode
       where E: Endpoint + Clone + Send + Sync + 'static;

    // Provided methods
    fn get<H, T, R>(self, handler: H) -> RouteNode
       where H: Handler<T, R>,
             T: Extractor,
             R: Responder { ... }
    fn ws<F, Fut>(self, handler: F) -> RouteNode
       where F: Fn(WebSocket) -> Fut + Clone + Send + Sync + 'static,
             Fut: Future<Output = ()> + Send + 'static { ... }
}
Expand description

Builder extension that turns a path literal into convenient routing nodes.

Required Methods§

Source

fn at<H, T, R>(self, handler: H) -> RouteNode
where H: Handler<T, R>, T: Extractor, R: Responder,

Attach a GET handler to the path.

Source

fn post<H, T, R>(self, handler: H) -> RouteNode
where H: Handler<T, R>, T: Extractor, R: Responder,

Attach a POST handler to the path.

Source

fn put<H, T, R>(self, handler: H) -> RouteNode
where H: Handler<T, R>, T: Extractor, R: Responder,

Attach a PUT handler to the path.

Source

fn delete<H, T, R>(self, handler: H) -> RouteNode
where H: Handler<T, R>, T: Extractor, R: Responder,

Attach a DELETE handler to the path.

Source

fn route(self, routes: impl Routes) -> RouteNode

Mount nested routes under the current path segment.

Source

fn endpoint<E>(self, method: Method, endpoint: E) -> RouteNode
where E: Endpoint + Clone + Send + Sync + 'static,

Attach an endpoint at the specified method and path.

Note: This is a low-level method; prefer using .at, .post, etc. for common HTTP methods. Especially when using OpenAPI, those methods will automatically generate documentation.

Provided Methods§

Source

fn get<H, T, R>(self, handler: H) -> RouteNode
where H: Handler<T, R>, T: Extractor, R: Responder,

Source

fn ws<F, Fut>(self, handler: F) -> RouteNode
where F: Fn(WebSocket) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = ()> + Send + 'static,

Attach a WebSocket handler that automatically performs the upgrade handshake.

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<P> CreateRouteNode for P
where P: Into<String>,