wasi-http-go

module
v0.0.0-...-9877ebc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2025 License: Apache-2.0

README

wasi-http-go

pkg.go.dev build status

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.

Directories

Path Synopsis
examples
basic command
counter command
proxy command
roundtrip command
This example is taken from https://github.com/dev-wasm/dev-wasm-go/blob/main/http/main.go demonstrates how to use the wasihttp package to make HTTP requests using the `http.Client` interface.
This example is taken from https://github.com/dev-wasm/dev-wasm-go/blob/main/http/main.go demonstrates how to use the wasihttp package to make HTTP requests using the `http.Client` interface.
internal
go/http/proxy
Package proxy represents the world "go:http/proxy@0.2.0".
Package proxy represents the world "go:http/proxy@0.2.0".
wasi/cli/environment
Package environment represents the imported interface "wasi:cli/environment@0.2.0".
Package environment represents the imported interface "wasi:cli/environment@0.2.0".
wasi/cli/exit
Package exit represents the imported interface "wasi:cli/exit@0.2.0".
Package exit represents the imported interface "wasi:cli/exit@0.2.0".
wasi/cli/run
Package run represents the exported interface "wasi:cli/run@0.2.0".
Package run represents the exported interface "wasi:cli/run@0.2.0".
wasi/cli/stderr
Package stderr represents the imported interface "wasi:cli/stderr@0.2.0".
Package stderr represents the imported interface "wasi:cli/stderr@0.2.0".
wasi/cli/stdin
Package stdin represents the imported interface "wasi:cli/stdin@0.2.0".
Package stdin represents the imported interface "wasi:cli/stdin@0.2.0".
wasi/cli/stdout
Package stdout represents the imported interface "wasi:cli/stdout@0.2.0".
Package stdout represents the imported interface "wasi:cli/stdout@0.2.0".
wasi/cli/terminal-input
Package terminalinput represents the imported interface "wasi:cli/terminal-input@0.2.0".
Package terminalinput represents the imported interface "wasi:cli/terminal-input@0.2.0".
wasi/cli/terminal-output
Package terminaloutput represents the imported interface "wasi:cli/terminal-output@0.2.0".
Package terminaloutput represents the imported interface "wasi:cli/terminal-output@0.2.0".
wasi/cli/terminal-stderr
Package terminalstderr represents the imported interface "wasi:cli/terminal-stderr@0.2.0".
Package terminalstderr represents the imported interface "wasi:cli/terminal-stderr@0.2.0".
wasi/cli/terminal-stdin
Package terminalstdin represents the imported interface "wasi:cli/terminal-stdin@0.2.0".
Package terminalstdin represents the imported interface "wasi:cli/terminal-stdin@0.2.0".
wasi/cli/terminal-stdout
Package terminalstdout represents the imported interface "wasi:cli/terminal-stdout@0.2.0".
Package terminalstdout represents the imported interface "wasi:cli/terminal-stdout@0.2.0".
wasi/clocks/monotonic-clock
Package monotonicclock represents the imported interface "wasi:clocks/monotonic-clock@0.2.0".
Package monotonicclock represents the imported interface "wasi:clocks/monotonic-clock@0.2.0".
wasi/clocks/wall-clock
Package wallclock represents the imported interface "wasi:clocks/wall-clock@0.2.0".
Package wallclock represents the imported interface "wasi:clocks/wall-clock@0.2.0".
wasi/filesystem/preopens
Package preopens represents the imported interface "wasi:filesystem/preopens@0.2.0".
Package preopens represents the imported interface "wasi:filesystem/preopens@0.2.0".
wasi/filesystem/types
Package types represents the imported interface "wasi:filesystem/types@0.2.0".
Package types represents the imported interface "wasi:filesystem/types@0.2.0".
wasi/http/incoming-handler
Package incominghandler represents the exported interface "wasi:http/incoming-handler@0.2.0".
Package incominghandler represents the exported interface "wasi:http/incoming-handler@0.2.0".
wasi/http/outgoing-handler
Package outgoinghandler represents the imported interface "wasi:http/outgoing-handler@0.2.0".
Package outgoinghandler represents the imported interface "wasi:http/outgoing-handler@0.2.0".
wasi/http/types
Package types represents the imported interface "wasi:http/types@0.2.0".
Package types represents the imported interface "wasi:http/types@0.2.0".
wasi/io/error
Package ioerror represents the imported interface "wasi:io/error@0.2.0".
Package ioerror represents the imported interface "wasi:io/error@0.2.0".
wasi/io/poll
Package poll represents the imported interface "wasi:io/poll@0.2.0".
Package poll represents the imported interface "wasi:io/poll@0.2.0".
wasi/io/streams
Package streams represents the imported interface "wasi:io/streams@0.2.0".
Package streams represents the imported interface "wasi:io/streams@0.2.0".
wasi/random/insecure
Package insecure represents the imported interface "wasi:random/insecure@0.2.0".
Package insecure represents the imported interface "wasi:random/insecure@0.2.0".
wasi/random/insecure-seed
Package insecureseed represents the imported interface "wasi:random/insecure-seed@0.2.0".
Package insecureseed represents the imported interface "wasi:random/insecure-seed@0.2.0".
wasi/random/random
Package random represents the imported interface "wasi:random/random@0.2.0".
Package random represents the imported interface "wasi:random/random@0.2.0".
wasi/sockets/instance-network
Package instancenetwork represents the imported interface "wasi:sockets/instance-network@0.2.0".
Package instancenetwork represents the imported interface "wasi:sockets/instance-network@0.2.0".
wasi/sockets/ip-name-lookup
Package ipnamelookup represents the imported interface "wasi:sockets/ip-name-lookup@0.2.0".
Package ipnamelookup represents the imported interface "wasi:sockets/ip-name-lookup@0.2.0".
wasi/sockets/network
Package network represents the imported interface "wasi:sockets/network@0.2.0".
Package network represents the imported interface "wasi:sockets/network@0.2.0".
wasi/sockets/tcp
Package tcp represents the imported interface "wasi:sockets/tcp@0.2.0".
Package tcp represents the imported interface "wasi:sockets/tcp@0.2.0".
wasi/sockets/tcp-create-socket
Package tcpcreatesocket represents the imported interface "wasi:sockets/tcp-create-socket@0.2.0".
Package tcpcreatesocket represents the imported interface "wasi:sockets/tcp-create-socket@0.2.0".
wasi/sockets/udp
Package udp represents the imported interface "wasi:sockets/udp@0.2.0".
Package udp represents the imported interface "wasi:sockets/udp@0.2.0".
wasi/sockets/udp-create-socket
Package udpcreatesocket represents the imported interface "wasi:sockets/udp-create-socket@0.2.0".
Package udpcreatesocket represents the imported interface "wasi:sockets/udp-create-socket@0.2.0".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL