1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use TokenStream;
use parse_macro_input;
/// Expands the `routes!` DSL (verbs, `resources!`, `namespace!`, `scope!`)
/// into an `axum::Router`. Merged in from the former `doido-router` crate.
/// Marks an impl block as a controller. Rewrites action methods into
/// axum-compatible handlers, wiring in any filters.
///
/// Filters are declared with the `#[before_action(...)]` / `#[after_action(...)]`
/// **helper attributes** on action methods; this macro parses and consumes them
/// while expanding the impl block, so there are no standalone
/// `before_action`/`after_action` macros to import:
///
/// ```ignore
/// #[controller]
/// impl PostsController {
/// #[before_action(require_auth)]
/// #[before_action(load_record, only = [show, edit])]
/// #[after_action(log_response)]
/// async fn show(ctx: &mut Context) -> Response { /* ... */ }
/// }
/// ```
///
/// `before_action` filters run in declaration order before the action and may
/// short-circuit by returning `Err(response)`; `after_action` filters run after.