pub struct Builder<M> { /* private fields */ }
Implementations§
source§impl<M> Builder<M>
impl<M> Builder<M>
pub fn extend<P: Into<Cow<'static, str>>, B: Into<Treemux>>( &self, path: P, routes: B )
pub fn scope<'b, P: Into<Cow<'b, str>>>( &'b mut self, path: P ) -> GroupBuilder<'b, Identity, M>where M: Layer<RequestHandler, Service = RequestHandler>,
pub fn not_found<H: Into<RequestHandler>>(&mut self, handler: H)where M: Layer<RequestHandler, Service = RequestHandler>,
sourcepub fn method_not_allowed<H: Into<RequestHandler>>(&mut self, handler: H)where
M: Layer<RequestHandler, Service = RequestHandler>,
pub fn method_not_allowed<H: Into<RequestHandler>>(&mut self, handler: H)where M: Layer<RequestHandler, Service = RequestHandler>,
Register a handler for when the path matches a different method than the requested one
sourcepub fn global_options<H: Into<RequestHandler>>(&mut self, handler: H)where
M: Layer<RequestHandler, Service = RequestHandler>,
pub fn global_options<H: Into<RequestHandler>>(&mut self, handler: H)where M: Layer<RequestHandler, Service = RequestHandler>,
Register a handler for when the path matches a different method than the requested one
pub fn handle_panics<H, R>(&mut self, handler: H)where R: Future<Output = Result<Response<Body>, Error>> + Send + 'static, H: Fn(Box<dyn Any + Send>) -> R + Send + Sync + 'static,
pub fn middleware<N>(self, middleware: N) -> Builder<Stack<N, M>>where N: Layer<M::Service, Service = M::Service>, M: Layer<RequestHandler, Service = RequestHandler>,
sourcepub fn into_service_with_context<T: Send + Sync + 'static>(
self,
context: T
) -> MakeRouterService<T>
pub fn into_service_with_context<T: Send + Sync + 'static>( self, context: T ) -> MakeRouterService<T>
Converts the Treemux
into a Service
which you can serve directly with Hyper
.
If you have an existing Service
that you want to incorporate a Treemux
into, see
Treemux::serve
.
// Our router...
let router = Treemux::builder();
// Convert it into a service...
let service = router.into_service();
// Serve with hyper
hyper::Server::bind(&([127, 0, 0, 1], 3030).into())
.serve(service)
.await?;
sourcepub fn into_service(self) -> MakeRouterService<()>
pub fn into_service(self) -> MakeRouterService<()>
Converts the Treemux
into a Service
which you can serve directly with Hyper
.
If you have an existing Service
that you want to incorporate a Treemux
into, see
Treemux::serve
.
// Our router...
let router = Treemux::builder();
// Convert it into a service...
let service = router.into_service();
// Serve with hyper
hyper::Server::bind(&([127, 0, 0, 1], 3030).into())
.serve(service)
.await?;