Attribute Macro controller

Source
#[controller]
Expand description

A macro that generates a into_router(_: State<_>) impl which automatically wires up all route’s and the given middlewares, path-prefix etc

§Syntax:

#[controller(
  path = "/asd",
  state = AppState,
  middleware=my_middleware
)]
impl ExampleController { /* ... */ }
  • path
    • optional, 0-1 allowed, defaults to "/"
    • A path to prefix .nest the routes in the controller Struct under
  • state
    • optional, 0-1 allowed, defaults to "()")
    • The type signature of the state given to the routes
  • middleware
    • optional, 0-n allowed, default to [] (no middlewares)
    • Middlewares to .layer in the created router