A WebAssembly component that serves HTTP requests and makes outbound HTTP
calls using wasihttp.DefaultClient (an http.Client over
wasihttp.Transport, an http.RoundTripper over
wasi:http/outgoing-handler), from go.bytecodealliance.org/wasi/wasihttp.
- 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].
wash dev
curl localhost:8000 # -> a random dog picture URL from dog.ceoOutbound hosts are declared in .wash/config.yaml
under workload.allowedHosts.
wash 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-client:0.1.0 build/http_client.wasm
kubectl apply -f deploy/deployment.yamlTwo things in the manifest have to match your cluster:
localResources.allowedHostson the component. Outbound HTTP is deny-by-default on a real host, and.wash/config.yamlis read only bywash dev, so the manifest carries its own copy of the allowlist (dog.ceo). Without it every outbound request fails.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-clientService. Keep it unique per workload: two workloads naming the same host become replicas of one route and split its traffic.
See the wasmCloud workload deployment quickstart for cluster setup.