This is a very experimental work in progress, use at your own risk!
PRs welcome!
xcaddy run --config caddy.json
curl localhost:2015
The server uses the WASI-HTTP specification.
There are examples here:
- Go (TinyGo) - https://github.com/brendandburns/caddy-wasm/tree/main/examples/tinygo
- Dotnet - https://github.com/dev-wasm/dev-wasm-dotnet/blob/main/www-wasi/Program.cs
- C - https://github.com/stealthrocket/wasi-go/blob/main/testdata/c/http/server.c
More to come in the future!
The wasm loader supports loading multiple versions of the same functionality and then chosing between them using a header.
To see this in action run:
# Run caddy pointed at the releases at https://github.com/brendandburns/caddy-wasm/releases
$ xcaddy run --config examples/github-versions.json
# Get the default version
$ curl localhost:2015
This is the beta release!
# Select a version
$ curl -H "x-caddy-wasm-version: 0.0.1" localhost:2015
This is the alpha release!
The specific configuration for this looks like:
{
"handle": [{
"handler": "wasm",
"wasm_file": "tinygo.wasm",
"wasm_github": "brendandburns/caddy-wasm"
}]
}
The wasm_file
directive specifies the file to look for in the release assets, releases without that file will be skipped.
The wasm_github
directive points to the repository where the releases are contained.
Currently there is also a glob loader that supports loading all files that match a glob:
{
"handle": [{
"handler": "wasm",
"wasm_file": "test/*.wasm"
}]
}
All files matching the glob (from the working directory where caddy
is launched) will be served.
Their "version" is the complete file path that matches the glob.
I'm sure there are many, please feel free to file issues.