Categorygithub.com/kong/proxy-wasm-go-filter-template
modulepackage
0.0.0-20240822202117-bc9a19a507f9
Repository: https://github.com/kong/proxy-wasm-go-filter-template.git
Documentation: pkg.go.dev

# README

Proxy-Wasm Go Filter Template

This repository contains a Proxy-Wasm filter that can be used as a reference to quickly start implementing new filters in Go.

This is a "hello-world" type filter performing a minimal operation and showing the basics of filter configuration: it simply adds a new header X-Greeting to a proxied response. You can pass the filter a JSON configuration in the format { "my_greeting": "Howdy!" } to change the value of the injected header.

Please refer to WasmX docs for the list of supported functions and entrypoints.

Requirements

  • tinygo - a Go compiler that can produce WebAssembly code.

Build

Once the Go environment is set up and tinygo is in the PATH, build the filter running make.

This will produce a .wasm file in the root of the project.

Testing

In the test/ folder you will find a shell script called demo.sh which builds the filter, then uses Docker to spin up a Kong Gateway container with the filter enabled, and issues a request using httpie. It uses the configuration test/config. You should see the X-Greeting header defined in that configuration in the httpie output.

# Packages

No description provided by the author