1 个稳定版本
2.0.0 | 2020 年 1 月 18 日 |
---|
#639 在 HTTP 服务器
1.5MB
33K SLoC
关于仓库
这是由 Nikolay Kim 创建的 actix-web 框架的分支。原始仓库托管在 actix/actix-web。原始代码: fafhrd91/actix-web。
Actix web 是一个简单、实用且极其快速的 Rust Web 框架。
- 支持 HTTP/1.x 和 HTTP/2.0 协议
- 流式传输和管道
- 长连接和慢请求处理
- 客户端/服务器 WebSocket 支持
- 透明内容压缩/解压缩 (br, gzip, deflate)
- 可配置的 请求路由
- 多部分流
- 静态资源
- 使用 OpenSSL 或 Rustls 支持的 SSL
- 中间件 (日志记录器、会话、CORS 等)
- 包含异步 HTTP 客户端
- 支持 Actix actor 框架
示例
依赖项
[dependencies]
actix-web = "2"
actix-rt = "1"
代码
use actix_web::{get, web, App, HttpServer, Responder};
#[get("/{id}/{name}/index.html")]
async fn index(info: web::Path<(u32, String)>) -> impl Responder {
format!("Hello {}! id:{}", info.1, info.0)
}
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| App::new().service(index))
.bind("127.0.0.1:8080")?
.run()
.await
}
更多示例
您可以考虑查看 此目录 以获取更多示例。
基准测试
许可协议
本项目许可协议为以下之一
- Apache 许可协议第 2 版 (LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT 许可协议 (LICENSE-MIT 或 http://opensource.org/licenses/MIT)
任选其一。
行为准则
对actix-web crate的贡献是在贡献者公约的条款下组织的,actix-web的维护者@fafhrd91承诺将介入维护该行为准则。
依赖项
~21–28MB
~595K SLoC