1
- # WASI Rust Sample
1
+ # Sample: ` wasi:http ` in Rust
2
2
3
3
[ ![ Open in GitHub Codespaces] ( https://github.com/codespaces/badge.svg )] ( https://codespaces.new/yoshuawuyts/rust-wasi-hello )
4
4
5
- An example project showing how to build an HTTP server for WASI 0.2 built in
6
- Rust.
5
+ An example project showing how to build a spec-compliant
6
+ [ ` wasi:http/proxy ` ] [ wasi-http ] server for WASI 0.2 written in Rust. This sample
7
+ includes several [ routes] ( #routes ) that showcase different behavior. This sample
8
+ can be run by any spec-compliant ` wasi:http/proxy ` server.
9
+
10
+ Each release of this sample is packaged up as a [ Wasm OCI image] [ wasm-oci-image ]
11
+ and published to the [ GitHub Packages Registry] [ gh-pkg ] . See the [ "Deploying
12
+ published artifacts"] [ using-arifacts ] section for more on how to fetch and run
13
+ the published artifacts.
7
14
8
15
## Routes
9
16
@@ -38,7 +45,7 @@ The HTTP server uses the `wasi:http/proxy` world. You can run it locally in a
38
45
$ cargo component serve
39
46
```
40
47
41
- ## Working with deployment artifacts
48
+ ## Deploying published artifacts
42
49
43
50
This project automatically published compiled Wasm Components as OCI to GitHub
44
51
Artifacts. You can pull the artifact with any OCI-compliant tooling and run it
@@ -47,8 +54,8 @@ latest published version from GitHub releases and run it in a local `wasmtime`
47
54
instance you can run the following command:
48
55
49
56
``` bash
50
- $ wkg pull ghcr.io/yoshuawuyts/ rust-wasi-hello :latest
51
- $ wasmtime serve rust -wasi-hello .wasm
57
+ $ wkg pull ghcr.io/bytecodealliance/sample-wasi-http- rust/sample -wasi-http-rust :latest
58
+ $ wasmtime serve sample -wasi-http-rust .wasm
52
59
```
53
60
54
61
For production workloads however, you may want to use other runtimes or
@@ -66,3 +73,7 @@ on the pull + serve pattern we've shown here.
66
73
Apache-2.0 with LLVM Exception
67
74
68
75
[ cargo-component ] : https://github.com/bytecodealliance/cargo-component
76
+ [ wasm-oci-image ] : https://tag-runtime.cncf.io/wgs/wasm/deliverables/wasm-oci-artifact/
77
+ [ gh-pkg ] : https://github.com/bytecodealliance/sample-wasi-http-rust/pkgs/container/sample-wasi-http-rust%2Fsample-wasi-http-rust
78
+ [ using-arifacts ] : #working-with-deployment-artifacts
79
+ [ wasi-http ] : https://github.com/WebAssembly/wasi-http
0 commit comments