#actix-web #validation #garde #actix

garde-actix-web

Actix-web 装饰器

11 个版本 (破坏性更新)

0.9.0 2024年7月5日
0.7.0 2024年5月3日
0.6.0 2024年2月29日
0.3.0 2023年12月1日
0.2.0 2023年10月3日

#436 in Web 编程

Download history 479/week @ 2024-05-02 343/week @ 2024-05-09 490/week @ 2024-05-16 364/week @ 2024-05-23 457/week @ 2024-05-30 411/week @ 2024-06-06 246/week @ 2024-06-13 521/week @ 2024-06-20 525/week @ 2024-06-27 829/week @ 2024-07-04 721/week @ 2024-07-11 569/week @ 2024-07-18 617/week @ 2024-07-25 832/week @ 2024-08-01 645/week @ 2024-08-08 468/week @ 2024-08-15

每月 2,657 次下载
3 个 Crates 中使用 (直接使用 2 个)

MIT 许可证

72KB
1.5K SLoC

Garde-actix-web Documentation Latest Version Build Status

用于 garde 的 Actix-web 包装器,garde 是一个 Rust 验证库。

安装

[dependencies]
garde = "0.20"
garde-actix-web = "0.9"

使用示例

简单地使用 garde-actix-web 暴露的类型作为 actix 类型的替代。

您的类型必须实现来自 gardeValidate。验证发生在 actix 的 FromRequest 调用期间。

如果有效载荷无效,则返回 400 错误(Path 为 404)。

可以通过 actix 的 dataapp_data 提供上下文,如果未找到,则使用默认值。

use actix_web::HttpResponse;
// instead of actix_web::web::Path
use garde_actix_web::web::Path;
use garde::Validate;

#[derive(Validate)]
struct MyStruct<'a> {
  #[garde(ascii, length(min = 3, max = 25))]
  username: &'a str,
}

fn test(id: Path<MyStruct>) -> HttpResponse {
  todo!()
}

name

功能标志

description 额外依赖项 serde_qs
启用 gardeserde_qs::actix::QsQuery<T> 的使用 garde 版本 启用 gardeserde_qs::actix::QsQuery<T> 的使用

兼容性矩阵

serde_qs 版本 garde-actix-web-version garde-actix-web 版本
0.14 0.12 0.1.x
0.15 0.12 0.2.x
0.16 0.12 0.3.x
0.17 0.12 0.4.x
0.18 0.12 0.5.x, 0.6.x
0.18 0.13 0.7.x
0.19 0.13 0.8.x
0.20 0.13 0.9.x

关于我们

Garde-actix-web 由 Netwo 提供。

我们使用此 Crate 满足内部需求,因此致力于其维护,但我们无法提供任何额外的保证。自行承担风险使用。

虽然我们不会投资我们不需要的功能,但我们欢迎接受您可能提出的任何拉取请求。

我们是一家位于法国的全远程电信行业公司。如果您想了解更多信息,请随时访问我们的职业页面

依赖项

~15–26MB
~474K SLoC