Skip to content

hyperlight-dev/hyperlight-wasm-http-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hyperlight-wasm http example

This is a minimal example of a hyperlight-wasm host application. It implements just enough of the wasi:http api to run the sample_wasi_http_rust server.

Prerequisites

  1. Rust, including the x86_64-unknown-none target (which may be installed via e.g. rustup target add x86_64-unknown-none)
  2. clang
  3. just (optional, but recommended)

If you want to follow the manual build instructions, you will also need:

  1. wasm-tools
  2. cargo-component
  3. hyperlight-wasm-aot

Simple setup

Building

just build

Running

just run

From another terminal, you can then test the server:

curl http://localhost:3000/
curl -w'\n' -d "hola mundo" http://127.0.0.1:3000/echo
curl -I -H "x-language: spanish" http://127.0.0.1:3000/echo-headers
# get the content of .gitignore from github.com/jprendes/hyperlight-wasm-http-example
curl -w'\n' http://127.0.0.1:3000/proxy

Manual setup

Building

Compile the WIT and set the environment variables used when building (both the host and the guest):

wasm-tools component wit hyperlight.wit -w -o hyperlight-world.wasm

Build:

cargo build

Running

Build the guest component:

cargo component build --release \
    --manifest-path guest/Cargo.toml \
    --target-dir target

AOT compile it:

cargo install hyperlight-wasm-aot
hyperlight-wasm-aot compile --component \
    target/wasm32-wasip1/release/sample_wasi_http_rust.wasm \
    target/wasm32-wasip1/release/sample_wasi_http_rust.bin

You can then run the server:

cargo run -- target/wasm32-wasip1/release/sample_wasi_http_rust.bin

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors