macro_rules! route_binding {
($entity:ty, $model:ty, $param:literal) => { ... };
}Expand description
Convenience macro to implement RouteBinding for a SeaORM model
DEPRECATED: This macro is no longer needed. Route model binding is now
automatic for any model whose Entity implements kit::database::Model.
Simply use the Model type in your handler parameter.
This macro implements the RouteBinding trait for a model, enabling
automatic route model binding with 404 handling.
§Arguments
$entity- The SeaORM Entity type (e.g.,user::Entity)$model- The SeaORM Model type (e.g.,user::Model)$param- The route parameter name (e.g.,"user")
§Example
ⓘ
use kit::route_binding;
// In your model file (e.g., models/user.rs)
route_binding!(Entity, Model, "user");
// Now you can use automatic binding in handlers:
#[handler]
pub async fn show(user: user::Model) -> Response {
json_response!({ "id": user.id, "name": user.name })
}§Route Definition
The parameter name must match your route definition:
ⓘ
routes! {
get!("/users/{user}", controllers::user::show),
}