Rust Web之Actix
添加依赖
cargo install actix-web
或
1 | [dependencies] |
实现
Get请求
分页查询
1 | // 定义get参数 |
main启动
1 | // 定义应用状态,这里保存数据库连接 |
跨域 CORS
cargo install actix-cors
1 | let cors = Cors::default() |
读取.env文件
引入依赖
cargo install dotenv
或
1 | dotenv_codegen = "0.15.0" |
在main中执行
1 | dotenvy::dotenv().ok(); |