@@ -14,43 +14,58 @@ The following HTTP routes are available from the component:
14
14
/sleep # Sleep for {ms} milliseconds
15
15
/echo # Echo the HTTP body
16
16
/echo-headers # Echo the HTTP headers
17
- /echo-trailers # Echo the HTTP trailers
18
- /upload # Echo uploaded blob
17
+ /upload # Echo uploaded blob
18
+ ```
19
+
20
+ Testing routes:
21
+
22
+ ``` bash
23
+ # Hello world
24
+ $ curl localhost:8080
25
+ # Sleep for {ms} milliseconds
26
+ $ curl localhost:8080/sleep/2000
27
+ # Echo the HTTP body
28
+ $ curl -d " Test echo body" localhost:8080/echo
29
+ # Echo the HTTP headers
30
+ $ curl -H " X-Test-Header: 123" localhost:8080/echo-headers
31
+ # Echo uploaded blob
32
+ $ echo " Hello World!" > test_file.txt
33
+ $ curl -H " Content-Type: text/plain" --data-binary @test_file.txt http://localhost:8080/upload
19
34
```
20
35
21
36
## Quick Start
22
- The project uses [ ` Wasmtime ` ] [ wasmtime ] as its runtime. However, if needed, it
23
- can easily be adjusted to use [ ` jco ` ] [ jco ] instead. For ` wasmtime ` installation,
37
+ The project uses [ ` Wasmtime ` ] [ wasmtime ] as its runtime. However, if needed, it
38
+ can easily be adjusted to use [ ` jco ` ] [ jco ] instead. For ` wasmtime ` installation,
24
39
simply run:
25
40
26
41
``` bash
27
42
$ curl https://wasmtime.dev/install.sh -sSf | bash
28
43
```
29
44
30
- The quickest way to start is by using [ ` just ` ] [ just ] .
45
+ The quickest way to start is by using [ ` just ` ] [ just ] .
31
46
``` bash
32
47
$ just serve # to build and serve the wasm component on `localhost:8080`
33
- $ curl 127.0.0.1 :8080 # to send requests to component.
48
+ $ curl localhost :8080 # to send requests to component.
34
49
```
35
50
36
51
Alternatively, run:
37
52
38
53
``` bash
39
54
$ npm install
40
- $ npm build
55
+ $ npm run build
41
56
$ wasmtime serve -S common dist/server.component.wasm
42
57
```
43
58
44
59
## See Also
45
60
46
- - [ sample-wasi-http-rust] ( https://github.com/bytecodealliance/sample-wasi-http- rust) An example ` wasi:http ` server component written in Rust.
61
+ - [ sample-wasi-http-rust] [ rust-example ] An example ` wasi:http ` server component written in Rust.
47
62
48
63
## License
49
64
50
65
Apache-2.0 with LLVM Exception
51
66
52
67
[ jco ] : https://github.com/bytecodealliance/jco
53
68
[ just ] : https://github.com/casey/just
54
- [ rust-sample] : https://github.com/bytecodealliance/sample-wasi-http-rust
69
+ [ rust-sample ] : https://github.com/bytecodealliance/sample-wasi-http-rust
55
70
[ wasi-http ] : https://github.com/WebAssembly/wasi-http
56
- [ wasmtime] : https://wasmtime.dev/
71
+ [ wasmtime ] : https://wasmtime.dev/
0 commit comments