Skip to content

ydnar/wasi-http-go

Repository files navigation

wasi-http-go

pkg.go.dev build status

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.

About

Prototype Go interface to wasi-http

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors 3

  •  
  •  
  •