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
use Adapter;
use Router as AxumRouter;
use State;
pub use ;
/// Trait for controllers with automatic dependency injection and interceptors support.
///
/// Controllers in Sword group related route handlers together and can declare
/// dependencies that will be automatically resolved and injected.
///
/// Controllers automatically implement the `Adapter` trait, making them registrable
/// as HTTP controllers within modules via `AdapterRegistry::register::<YourController>()`.
///
/// Use the `#[controller]` macro to automatically implement this trait.
///
/// # Example
///
/// ```rust,ignore
/// use sword::prelude::*;
///
/// #[controller("/api/users")]
/// struct UserController {
/// service: Arc<UserService>,
/// }
///
/// #[routes]
/// impl UserController {
/// #[get("/")]
/// async fn list(&self) -> JsonResponse {
/// // Handler logic
/// }
/// }
/// ```