Wasmo Docs

Search

Wasmo CLI

Installation

This project can be installed and compiled from source with this Cargo command:

$ cargo install wasmo
or
$ brew tap maif/wasmo
$ brew install wasmo

Additionally there are precompiled artifacts built on CI which are available for download as well.

Installation can be confirmed with:

$ wasmo --version

Subcommands can be explored with:

$ wasmo help

Quick start

wasmo init --name=my-first-plugin --template=js
wasmo build --host=OneShotDocker --path=my-first-plugin

Then open the content of your my-first-plugin folder. You should find the generated WASM binary named my-first-plugin-1.0.0.wasm.

§Specifying language and product to create a plugin

With the newer version, you should create a plugin by specifying the language to be used, the target product, and the template.

wasmo init --name=my-first-plugin --language=js --product=otoroshi --product_template=ACCESS_CONTROL

The product template parameter accepts multiple values:

  • REQUEST_TRANSFORMER: Transform the content of the request with a wasm plugin
  • RESPONSE_TRANSFORMER: Transform the content of a response with a wasm plugin
  • ACCESS_CONTROL: Delegate route access to a wasm plugin
  • BACKEND: This plugin can be used to use a wasm plugin as backend
  • ROUTE_MATCHER: This plugin can be used to use a wasm plugin as route matcher
  • SINK: Handle unmatched requests with a wasm plugin
  • PRE_ROUTE: This plugin can be used to use a wasm plugin as in pre-route phase

You can also create a Izanami plugin

wasmo init --name=my-first-plugin --language=js --product=izanami

For the moment, Izanami doesn't provide any templates.

If you want to start from scratch, without targeting any products

wasmo init --name=my-first-plugin --language=js

§Or selecting a template

You can now optionally start a new plugin from a template by appending --template=[template-name] to the creation command.

If you don't pass a template, Wasmo will list the available templates. There are listed by product :

  • empty template : js, ts, opa, go and rust
  • Otoroshi template : otoroshi_go, otoroshi_rust, otoroshi_opa, otoroshi_ts, otoroshi_js
  • Izanami template : izanami_js, izanami_go, izanami_rust, izanami_opa, izanami_ts
wasmo init --name=my-first-plugin --template=[template-name] --path=[output-directory]

Running this command with any of theses templates will create a directory called my-first-plugin inside the specified output directory (or the current if omitted). Inside that directory, it will generate the initial project structure with the metadata file pre-filled with the name of your plugin.

§Creating a production WASM binary

wasmo build starts the process to build a WASM binary of your plugin. Inside the plugin directory will be your WASM binary and sources.

You have two ways to build your plugin:

Assuming we want to build our my-first-plugin locally. Enter the following command to start the build.

wasmo build --host=OneShotDocker --path=my-first-plugin

Let's explain these 3 parameters:

  • the path parameter is explicitly used to indicate the plugin to build
  • the host indicates which kind of Wasmo server used. The pratical way is to use Docker or OneShotDocker because it prevents to install a Wasmo server by deploying, inside your locally Docker, a new Wasmo container. The last possible value is Remote and can be used to specify with a URI the remote Wasmo server used.