A WebAssembly component that serves HTTP requests using Go's standard
net/http types via go.bytecodealliance.org/wasi/wasihttp, and logs through
wasi:logging with go.bytecodealliance.org/wasi/wasilog.
- Go 1.27+
wash2.x
On a fresh clone, download the Go modules first:
go mod downloadcomponentize-go reads the SDK's WIT straight out of the module cache and does
not fetch it itself, so until the modules are downloaded wash dev and
wash build fail with failed to read path for WIT [wit].
Start a local dev loop (builds the component and serves it, rebuilding on change):
wash devThen try the endpoints:
curl localhost:8000
curl localhost:8000/headers
curl -X POST -d key=value localhost:8000/form
curl -X POST -d hello localhost:8000/post
curl localhost:8000/error # -> 500wash buildPush the component to an OCI registry, point image in
deploy/deployment.yaml at it, and apply the manifest:
wash oci push ghcr.io/<your-org>/http-server:0.1.0 build/http_server.wasm
kubectl apply -f deploy/deployment.yamlTwo things in the manifest have to match your cluster:
config.hoston thewasi:httpentry. The host routes each request to a workload by itsHostheader, so set this to the hostname your ingress forwards to thehttp-serverService. Keep it unique per workload: two workloads naming the same host become replicas of one route and split its traffic.wasi:loggingstays listed. A real host binds only the interfaces the manifest names, and this component importswasi:logging; without the entry it fails to start witha matching implementation was not found in the linker.wash devderives it from the imports, so dev never shows it.
See deploy/deployment.yaml for the WorkloadDeployment
definition and the wasmCloud workload deployment
quickstart
for cluster setup.