859

0

Actix Web

Actix Web 是一个功能强大、实用且速度极快的 Rust Web 框架

Actix Web

Actix Web 是一个功能强大、实用且速度极快的 Rust Web 框架

板条箱.io 文档 MSRV MIT 或 Apache 2.0 许可 依赖状态 CI 编解码器 下载 在 Discord 上聊天

特征

  • 支持HTTP/1.xHTTP/2
  • 流和流水线
  • 带有可选宏的强大请求路由
  • 完全兼容Tokio
  • 保持活动和缓慢的请求处理
  • 客户端/服务器WebSocket支持
  • 透明内容压缩/解压缩(br、gzip、deflate、zstd)
  • 多部分流
  • 静态资产
  • 使用 OpenSSL 或 Rustls 的 SSL 支持
  • 中间件(记录器、会话、CORS 等
  • 与HTTP 客户端集成awc
  • 在 Rust 1.59+ 上运行

文档

例子

依赖项:

[dependencies]
actix-web = "4"

代码:

use actix_web::{get, web, App, HttpServer, Responder};

#[get("/hello/{name}")]
async fn greet(name: web::Path<String>) -> impl Responder {
    format!("Hello {name}!")
}

#[actix_web::main] // or #[tokio::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| {
        App::new().service(greet)
    })
    .bind(("127.0.0.1", 8080))?
    .run()
    .await
}

更多示例

您可以考虑查看此目录以获取更多示例。

基准

根据TechEmpower Framework Benchmark提供的最快的 Web 框架之一。

执照

该项目根据以下任一许可证获得许可,您可以选择:

行为守则

对 actix-web 存储库的贡献是根据贡献者契约的条款组织的。Actix 团队承诺进行干预以维护该行为准则。