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
use AppError;
/// 框架标准 Result 类型
///
/// 用于所有可能返回错误的操作,提供统一的错误处理体验
///
/// # 示例
///
/// ```no_run
/// use miko::error::{AppError, AppResult};
/// use miko::extractor::Json;
/// use serde::{Deserialize, Serialize};
///
/// // Define request and response structures
/// #[derive(Deserialize)]
/// struct UserData {
/// email: String,
/// }
///
/// #[derive(Serialize)]
/// struct User {
/// id: u64,
/// email: String,
/// }
///
/// async fn create_user(Json(data): Json<UserData>) -> AppResult<Json<User>> {
/// // Validation
/// if data.email.is_empty() {
/// return Err(AppError::BadRequest("Email is required".to_string()));
/// }
///
/// // Business logic...
/// let user = User { id: 1, email: data.email.clone() };
/// Ok(Json(user))
/// }
/// ```
pub type AppResult<T> = ;