Package wasihttp
implements wasi:http/proxy
for Go using standard net/http
interfaces.
To use this package, you’ll need:
Example code using this package can be found in the examples directory. To run the examples with tinygo run
, you’ll need to install a development build of TinyGo that supports wasmtime serve
(0.35.0-dev or later with this PR merged).
A simple net/http
server. Run with tinygo run -target wasip2-http.json ./main.go
.
package main
import (
"net/http"
_ "github.com/ydnar/wasi-http-go/wasihttp" // enable wasi-http
)
func init() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("X-Go", "Gopher")
w.Write([]byte("Hello world!\n"))
})
}
func main() {}
This project is licensed under the Apache 2.0 license with the LLVM exception. See LICENSE for more details.