repository
0.0.0-20241217022132-333b54c12051
Repository: https://github.com/ydnar/wasi-http-go.git
Documentation: pkg.go.dev
# README
wasi-http-go
wasi-http for Go
Package wasihttp
implements wasi:http/proxy
for Go using standard net/http
interfaces.
Prerequisites
To use this package, you’ll need:
Examples
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).
Server
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() {}
License
This project is licensed under the Apache 2.0 license with the LLVM exception. See LICENSE for more details.