Trait RouterBuilder

Source
pub trait RouterBuilder {
    // Required method
    fn handle<P, H>(&self, method: Method, path: P, handler: H)
       where P: Into<String>,
             H: Into<RequestHandler>;

    // Provided methods
    fn get<P, H>(&mut self, path: P, handler: H)
       where P: Into<String>,
             H: Into<RequestHandler> { ... }
    fn head<P, H>(&mut self, path: P, handler: H)
       where P: Into<String>,
             H: Into<RequestHandler> { ... }
    fn options<P, H>(&mut self, path: P, handler: H)
       where P: Into<String>,
             H: Into<RequestHandler> { ... }
    fn post<P, H>(&mut self, path: P, handler: H)
       where P: Into<String>,
             H: Into<RequestHandler> { ... }
    fn put<P, H>(&mut self, path: P, handler: H)
       where P: Into<String>,
             H: Into<RequestHandler> { ... }
    fn patch<P, H>(&mut self, path: P, handler: H)
       where P: Into<String>,
             H: Into<RequestHandler> { ... }
    fn delete<P, H>(&mut self, path: P, handler: H)
       where P: Into<String>,
             H: Into<RequestHandler> { ... }
}

Required Methods§

Source

fn handle<P, H>(&self, method: Method, path: P, handler: H)
where P: Into<String>, H: Into<RequestHandler>,

Insert a value into the router for a specific path indexed by a key.

use treemux::{Treemux, RouterBuilder};
use hyper::{Response, Body, Method, Request};

let mut router = Treemux::builder();
router.handle(Method::GET, "/teapot", |_: Request<Body>| {
    async { Ok(Response::new(Body::from("I am a teapot!"))) }
});
let router: Treemux = router.into();

Provided Methods§

Source

fn get<P, H>(&mut self, path: P, handler: H)
where P: Into<String>, H: Into<RequestHandler>,

Register a handler for GET requests

Source

fn head<P, H>(&mut self, path: P, handler: H)
where P: Into<String>, H: Into<RequestHandler>,

Register a handler for HEAD requests

Source

fn options<P, H>(&mut self, path: P, handler: H)
where P: Into<String>, H: Into<RequestHandler>,

Register a handler for OPTIONS requests

Source

fn post<P, H>(&mut self, path: P, handler: H)
where P: Into<String>, H: Into<RequestHandler>,

Register a handler for POST requests

Source

fn put<P, H>(&mut self, path: P, handler: H)
where P: Into<String>, H: Into<RequestHandler>,

Register a handler for PUT requests

Source

fn patch<P, H>(&mut self, path: P, handler: H)
where P: Into<String>, H: Into<RequestHandler>,

Register a handler for PATCH requests

Source

fn delete<P, H>(&mut self, path: P, handler: H)
where P: Into<String>, H: Into<RequestHandler>,

Register a handler for DELETE requests

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<'a, M, S> RouterBuilder for GroupBuilder<'a, M, S>

Source§

impl<M> RouterBuilder for Builder<M>
where M: Layer<RequestHandler, Service = RequestHandler>,