Skip to content

About

Create HTTP servers in WebAssembly

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTTP Server

A wazero host module, ABI and guest SDK enabling WASI modules to register as HTTP servers.

Host Module

Go Reference Go Report Card Go Coverage

First register the host module with the runtime

import (
	"context"
	_ "embed"
	"net"
	"net/http"

	"github.com/tetratelabs/wazero"
	"github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1"

	"github.com/pantopic/wazero-pool"

	"github.com/pantopic/ext-http-server/host-wazero"
)

//go:embed test\.wasm
var wasm []byte

func main() {
	ctx := context.Background()
	runtime := wazero.NewRuntimeWithConfig(ctx, wazero.NewRuntimeConfig())
	wasi_snapshot_preview1.MustInstantiate(ctx, runtime)

	hostModule := wazero_http_server.New()
	hostModule.Register(ctx, runtime)

	httpServer := http.NewServer()
	pool, err := wazeropool.New(ctx, runtime, wasm)
	if err != nil {
		panic(err)
	}
	hostModule.RegisterServices(ctx, httpServer, pool)

	httpListener, _ := net.Listen(`tcp`, `:8000`)
	httpServer.Serve(httpListener)

	// ...
}

Roadmap

This project is in alpha. Breaking API changes should be expected until Beta.

  • v0.0.x - Alpha
    • Stabilize API
  • v0.x.x - Beta
    • Finalize API
    • Test in production
  • v1.x.x - General Availability
    • Proven long term stability in production

About

Create HTTP servers in WebAssembly

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages