5 releases (3 breaking)
0.4.0 | Nov 19, 2021 |
---|---|
0.3.0 | Nov 13, 2021 |
0.2.0 | Nov 11, 2021 |
0.1.1 | Nov 11, 2021 |
0.1.0 | Nov 9, 2021 |
#1485 in WebAssembly
66KB
1.5K
SLoC
WASI Network Interface
This library allows applications compiled to WASI to have access to HTTP and HTTPS queries that support the interface.
Consuming this library is simple, simply link to it and use the builder to construct an API request.
On the server side the following must be implemented
- Create a virtual file under /dev/web
- Listen for writes to the file that terminate with a \n
- The first line received is the URL to connect to
- The second line is the HTTP method to use (e.g. GET,PUT,etc)
- The third line is an encoded set of headers (base64 encoded JSON representation of a Vec<(String, String)>
- The last line is the data to set (zero bytes means no data)
- Then make the HTTP request and allow the file handle to read the data
Missing features
While it is possible to add request headers, it is not yet possible read response headers as the ability to iterate them using web-sys is not yet implemented upstream
Testing
You can test your WASI program by uploading it to wapm.io and then heading over to the Tokera Shell
Dependencies
~3–14MB
~195K SLoC