bundle!() { /* proc-macro */ }Expand description
Collects bundle parts (routes, tasks, signals) into a Bundle for composition and registration.
Bundles are the primary unit for organizing and composing application components.
Each handler must be annotated with appropriate macros (#[route], #[cron], #[periodic], etc.).
§Syntax
ⓘ
bundle! {
handler1,
handler2,
...,
tags = ["tag1", "tag2"] // optional, applies only to routes
}§Options
tags- Optional array of tags to apply to all routes in the bundle. These tags extend (not replace) any tags defined on individual routes. Note: tags only apply to route parts, not other bundle parts.
§Examples
ⓘ
// Bundle without tags
let user_bundle = bundle! {
get_user, // #[route]
create_user, // #[route]
sync_users, // #[cron]
};
// Bundle with tags - extends individual route tags
let api_bundle = bundle! {
tags = ["api", "v1"],
get_user,
create_user,
};
// Compose bundles
let all_bundles = bundle! {
user_bundle,
api_bundle,
};§Notes
- Handlers must be annotated with
#[route],#[cron],#[periodic],#[pgnotify], or#[signal] - Handlers can be free functions or references to IntoBundle types
- Tags are additive and only apply to route parts
- Returns a
Bundlethat implementsIntoBundle