对于HTTP客户端,可以使用。它还可以与serde无缝集成,以允许从HTTP解析JSON:
[dependencies]
reqwest = { version = "0.10", features = ["json"] }
tokio = { version = "0.2", features = ["full"] }
tokio默认情况下Rust不附带异步运行时,tokio大约等同于Golang运行时帮助处理的大多数重要事项。简单实例如下:
运行此命令:
cargo run
...
Finished dev [unoptimized + debuginfo] target(s) in 3.31s
Running `target/debug/webcer`
Status: 200 OK
Body:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>hyper.rs | hyper</title>
<meta name="description" content="">
结合其他功能,reqwest可以做作为一个功能强大的HTTP客户端。