当前位置:网站首页>Tide - 基于 async-std 的 Rust-web 框架
Tide - 基于 async-std 的 Rust-web 框架
2022-06-30 16:59:00 【ruonou.com】
Tide 是小型而实用的 Rust web 应用程序框架,为快速开发而构建。它提供了一组健壮的特性,使得构建异步 web 应用程序和 API 更加容易、更为有趣。
下面的示例中,将创建 HTTP 服务器,接收 JSON 文本,对其进行验证,并用确认消息进行响应。我们看看是多么简单——
use tide::prelude::*;
use tide::Request;
#[derive(Debug, Deserialize)]
struct Animal {
name: String,
legs: u8,
}
#[async_std::main]
async fn main() -> tide::Result<()> {
tide::log::start();
let mut app = tide::new();
app.at("/orders/shoes").post(order_shoes);
app.listen("127.0.0.1:8080").await?;
Ok(())
}
async fn order_shoes(mut req: Request<()>) -> tide::Result {
let Animal { name, legs } = req.body_json().await?;
Ok(format!("Hello, {}! I've put in an order for {} shoes", name, legs).into())
}
相较于 actix-web,本人更喜欢 Tide。以前个人是 actix-web 用户,用其开发过基于 actix-web、juniper(Rust 的 graphql 实现)、postgresql、react 等的 web 综合应用,但先经我比较后,兴趣更多放在了 Tide 和 async-graphql 之上。
因为个人喜欢,所以向各位朋友推荐。
Tide 在生产环境的实践示例项目,请参阅 yazhijia(github 仓库)(将持续升级)
- 纯粹 Rust 技术栈实现的博客系统,有兴趣请访问演示站点:https://blog.budshome.com。
- 后端(backend)主要提供 graphql 服务,使用了 tide, async-graphql, jsonwebtoken, mongodb 等相关 crate。
- 前端(frontend)提供 web 应用服务,使用了 tide, rhai, surf, graphql_client, handlebars-rust, cookie 等相关 crate。
关于清洁的模板项目,采用了纯粹的 Rust 技术栈。包括(将持续升级):
- Rust - 中文资料集萃
- Tide - 中文文档
- async-graphql - 中文文档
- mongodb & mongo-rust-driver
- Surf
- graphql_client
- handlebars-rust
- jsonwebtoken
- cookie-rs
请参阅 github 仓库 tide-graphql-mongodb。目前实现了如下功能(将持续升级):
- 用户注册
- 使用 PBKDF2 对密码进行加密(salt)和散列(hash)运算
- 整合 JWT 鉴权的用户登录
- 密码修改
- 资料更新
- 用户查询和变更
- 项目查询和变更
- 使用基于 Rust 实现 graphql-client 获取 GraphQL 服务端数据
- 渲染 GraphQL 数据到 handlebars-rust 模板引擎
谢谢您的阅读。
边栏推荐
- Synchronized summary
- 基于SSH的通讯网络电子计费系统
- 力扣解法汇总1175-质数排列
- MySQL reports that the column timestamp field cannot be null
- Switching routing (VLAN) experiment
- Tsinghua only ranks third? 2022 release of AI major ranking of Chinese Universities of soft science
- Hcip (Huawei Senior Network Security Engineer) (Experiment 8) (MPLS basic experiment)
- The secondary menu of the magic article system v5.4.0 supports the optimization of form display
- Flutter custom component
- Flink series: checkpoint tuning
猜你喜欢

Volcano engine was selected into the first "panorama of edge computing industry" in China

Rainbow Brackets 插件的快捷键

News management system based on SSM

基于SSM的新闻管理系统

漏洞复现----38、ThinkPHP5 5.0.23 远程代码执行漏洞

Mo Tianlun salon | Tsinghua qiaojialin: Apache iotdb, originated from Tsinghua, is building an open source ecological road

Type ~ storage ~ variable in C #

C# Winform程序界面优化实例

What will be the game changes brought about by the meta universe?

Solve the problem of unable to connect to command metric stream and related problems in the hystrix dashboard
随机推荐
C# Winform程序界面优化实例
Post MSF infiltration summary
力扣解法汇总1175-质数排列
Solve the problem of unable to connect to command metric stream and related problems in the hystrix dashboard
The new Post-00 Software Test Engineer in 2022 is a champion
Unity实战之一个脚本实现雷达图
ASP. Net authentication code login
基於SSH的網上商城設計
Deep understanding of JVM (I) - memory structure (I)
Php8.0 environment detailed installation tutorial
助力极致体验,火山引擎边缘计算最佳实践
Redis (IX) - enterprise level solution (II)
Animesr: learnable degradation operator and new real world animation VSR dataset
Advanced embedded application of uni app [day14]
Small tools (3) integration knife4j3.0.3 interface document
Mo Tianlun salon | Tsinghua qiaojialin: Apache iotdb, originated from Tsinghua, is building an open source ecological road
Advanced customization of uni app [day13]
ASP. Net password encryption and password login
Shortcut keys for the rainbow brackets plug-in
ASP. Net generate verification code