pub trait ApiRoute<S>{
// Required method
fn api_route<H, T>(
self,
route_info: (&'static str, &'static str),
handler: H,
) -> Self
where H: Handler<T, S>,
T: 'static;
}Expand description
Extension trait for registering routes using the macro-generated
(&'static str, &'static str) route info tuple.
This is the enforcement contract: the HTTP verb in the route info tuple
(set by the #[get], #[post], etc. annotation) is the sole authority on
the HTTP method. It is impossible to accidentally register a #[get]
handler as a POST endpoint.
§Example
ⓘ
// health_check is annotated #[get("/health")], so __health_check_route is
// ("/health", "GET"). api_route enforces that it is registered as GET.
router.api_route(__health_check_route, health_check)Required 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.