pub trait AddRouterExt {
// Required methods
fn add_router<T>(&self, router: impl Into<Arc<T>>)
where T: RouterBuilder + 'static;
fn has_router<T>(&self) -> bool
where T: RouterBuilder + 'static;
}Expand description
Registers concrete RouterBuilder instances on the public HTTP server.
This extension lives on AppContext, so routers can be registered both
while configuring the AppBuilder and from within a plugin’s build. A
router is identified by its type: at most one instance of a given type may be
registered.
Registration does not require HttpServerPlugin; if the plugin is never
added the router is simply never served.
Required Methods§
Sourcefn add_router<T>(&self, router: impl Into<Arc<T>>)where
T: RouterBuilder + 'static,
fn add_router<T>(&self, router: impl Into<Arc<T>>)where
T: RouterBuilder + 'static,
Registers router on the public HTTP server.
The router is stored under its concrete type T. To expose several
distinct sets of routes use distinct types; a single type that needs many
routes should build them all in its RouterBuilder implementation.
§Panics
Panics if a router of type T is already registered on this server.
Guard with has_router when the same type may
be registered more than once (for example from several bundles).
Sourcefn has_router<T>(&self) -> boolwhere
T: RouterBuilder + 'static,
fn has_router<T>(&self) -> boolwhere
T: RouterBuilder + 'static,
Returns whether a router of type T is registered on the public server.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".