Skip to main content

Crate xmacros

Crate xmacros 

Source
Expand description

Publishable procedural macros for local dependency injection and Axum routes.

Use routes as #[get("/health", state = AppState)]; the explicit state argument makes generated routers reusable outside this workspace.

Attribute Macros§

body
Preserve this annotation for the owning route or module macro.
controller
Generate a controller router from method route attributes.
delete
Declare an HTTP DELETE handler.
exception
Preserve this annotation for the owning route or module macro.
extension
Preserve this annotation for the owning route or module macro.
get
Declare an HTTP GET handler.
global
Marks a module as globally visible. It is consumed by #[module].
guard
Declare guards or authorization policy beneath module/controller/routes, or on a routed handler.
head
Declare an HTTP HEAD handler.
header
Preserve this annotation for the owning route or module macro.
injectable
Generate dependency-injection factories for a struct.
interceptor
Preserve this annotation for the owning route or module macro.
middleware
Declare ordered controller or route middleware under #[controller] or #[routes].
module
Declare module providers, imports, and exported dependencies.
on_bootstrap
Preserve this annotation for the owning route or module macro.
on_module_destroy
Preserve this annotation for the owning route or module macro.
on_module_init
Preserve this annotation for the owning route or module macro.
on_shutdown
Preserve this annotation for the owning route or module macro.
options
Declare an HTTP OPTIONS handler.
param
Preserve this annotation for the owning route or module macro.
patch
Declare an HTTP PATCH handler.
permissions
Declare guards or authorization policy beneath module/controller/routes, or on a routed handler.
post
Declare an HTTP POST handler.
put
Declare an HTTP PUT handler.
query
Preserve this annotation for the owning route or module macro.
request
Preserve this annotation for the owning route or module macro.
roles
Declare guards or authorization policy beneath module/controller/routes, or on a routed handler.
routes
Generate an Axum router for an inherent controller implementation.
scope
Selects the provider lifecycle used by #[injectable] (singleton, transient, or request).
state
Preserve this annotation for the owning route or module macro.
test_module
Preserve this annotation for the owning route or module macro.
validate
Preserve this annotation for the owning route or module macro.

Derive Macros§

Injectable
Derive dependency-injection factories without changing the struct declaration.