pub trait AddRouterServiceExt {
// Required methods
fn add_router_service<T>(&mut self) -> &mut Self
where T: Service<Handle = Arc<T>> + RouterBuilder + 'static;
fn has_router_service<T>(&self) -> bool
where T: Service<Handle = Arc<T>> + RouterBuilder + 'static;
}Expand description
Registers routers resolved from the dependency-injection container on the public HTTP server.
Unlike AddRouterExt, the router type T is a Service: it is built by
the container (together with its dependencies) and its handle is then
registered as a RouterBuilder. The service is added automatically if it
is not already present.
Required Methods§
Sourcefn add_router_service<T>(&mut self) -> &mut Self
fn add_router_service<T>(&mut self) -> &mut Self
Registers the Service T and serves its routes on the public server.
§Panics
Panics if T is already registered as a router service (its provider
plugin would be added twice); guard with
has_router_service when this
can happen. Building the App additionally panics if T is registered
both as a service router and as an instance via
AddRouterExt::add_router, since a type may back at most one router.
Sourcefn has_router_service<T>(&self) -> bool
fn has_router_service<T>(&self) -> bool
Returns whether T is registered as a router service on the public
server.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".