Skip to content

biangeevibegx/caddy-wasm

Repository files navigation

WebAssembly extension for Caddy

This is a very experimental work in progress, use at your own risk!

PRs welcome!

Running

xcaddy run --config caddy.json
curl localhost:2015

Building WASM modules

The server uses the WASI-HTTP specification.

There are examples here:

More to come in the future!

Version loading

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.

Other version loaders

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.

Bugs/Features

I'm sure there are many, please feel free to file issues.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published