#[controller]Expand description
Declares the path prefix for a controller type.
#[controller] is valid on structs that own HTTP handler methods. It is
metadata-generating behavior by itself: it records the controller prefix and
exposes controller metadata used by #[routes], CLI route inspection, and
OpenAPI tooling.
Basic syntax:
ⓘ
#[controller("/users")]
struct UsersController {
service: UsersService,
}#[controller("/users")] combines with route methods inside a #[routes]
impl block. The final route path is the controller prefix plus each method’s
route path, for example "/users" and "/:id" become "/users/:id".
Common errors are missing the string literal path, using an empty dynamic
segment such as "/:", or expecting this macro alone to register Tower
routes. Executable routing is generated by #[routes].