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
//! # Controllers: the code that answers requests
//!
//! A controller groups the handlers for one feature:
//!
//! ```ignore
//! pub struct PostController;
//!
//! #[controller]
//! impl PostController {
//! /// Every post (this line shows up in the API docs).
//! async fn index() -> Result<Json<Vec<Post>>> { ... }
//! }
//! ```
//!
//! A handler is an `async fn`: its arguments say what it needs from the
//! request (the body, a URL parameter, the logged-in user...) and it returns
//! the response. Connect it to a URL in `src/routes/api.rs` (or `web.rs`
//! for pages): `route.get("/posts", PostController::index)`.
//!
//! - Create a new one with `chy make:controller CommentController`. It is
//! added to this file for you.
//! - Standard names: `index` (list), `store` (create), `show` (one),
//! `update`, `destroy` (delete). With them, `route.resource("/posts", PostController)`
//! adds all five routes in one line.
//! - Keep handlers short: input types go in `requests/`, table structs in `models/`.
pub use AuthController;
pub use PostController;
pub use RealtimeController;
pub use StatsController;
pub use UploadController;