2 releases

Uses new Rust 2024

new 0.1.4 Mar 28, 2025
0.1.3 Mar 27, 2025

#2 in #示例

31 downloads per month

MIT license

26KB
366 lines

Baize ToolKit


lib.rs:

BaizeKit API 模块

该模块提供了用于构建 Web API 的工具集,包括:

  • 请求处理:分页、参数验证等
  • 响应封装:统一响应格式、错误处理等
  • 数据提取:请求参数提取、认证信息等

功能特性

  • 统一的请求和响应格式
  • 内置的分页支持
  • 完善的错误处理机制
  • 支持 OpenAPI 文档生成

示例

use baizekit_api::prelude::*;
use axum::extract::Json;

async fn handler(page: PageRequest) -> Result<ApiOK<Page<Data>>, ApiError<Error>> {
    // 处理请求
    let data = Page {
        total: 100,
        current: page.current,
        size: page.size,
        data: vec![],
    };
    Ok(ApiOK::with_data(data))
}

Dependencies

~7–14MB
~164K SLoC