9个重大版本更新
0.10.0 | 2022年6月15日 |
---|---|
0.9.0 | 2022年2月19日 |
0.8.0 | 2022年1月21日 |
0.7.0 | 2021年11月15日 |
0.2.0 | 2021年3月24日 |
#1389 在 WebAssembly
65 每月下载量
28KB
632 代码行
wasi-experimental-http-wasmtime
Wasmtime中的实验性HTTP库
为Wasmtime运行时添加支持
添加支持的 easiest 方法是使用 Wasmtime链接器
let store = Store::default();
let mut linker = Linker::new(&store);
let wasi = Wasi::new(&store, ctx);
// link the WASI core functions
wasi.add_to_linker(&mut linker)?;
// link the experimental HTTP support
let allowed_hosts = Some(vec!["https://postman-echo.com".to_string()]);
let max_concurrent_requests = Some(42);
let http = HttpCtx::new(allowed_domains, max_concurrent_requests)?;
http.add_to_linker(&mut linker)?;
Wasmtime实现还启用了 allowed domains - 一个可选且可配置的域名或主机列表,允许 guest 模块向其发送请求。如果传递 None
或空向量,则 guest 模块 不允许 向任何服务器发送 HTTP 请求。(注意传递的主机必须指定协议 - 即 https://my-domain.com
或 http://192.168.0.1
,如果请求子域名,则子域名必须在允许列表中。更多示例请参阅库测试)。
依赖项
~24–38MB
~654K SLoC