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§
Sourcefn handle<P, H>(&self, method: Method, path: P, handler: H)
fn handle<P, H>(&self, method: Method, path: P, handler: H)
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§
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.