components-contrib/middleware/http/wasm
Josh van Leeuwen d8ac01bc76
Update go -> 1.24.1 & golangci-lint -> 1.64.6 (#3699)
Signed-off-by: joshvanl <me@joshvanl.dev>
2025-03-12 13:50:32 -07:00
..
example fix all wasm guests build and refresh with TinyGo 0.28.1 (#3377) 2024-03-09 16:54:17 +01:00
internal Update go -> 1.24.1 & golangci-lint -> 1.64.6 (#3699) 2025-03-12 13:50:32 -07:00
Makefile Adds http-wasm middleware to replace basic (#2239) 2022-11-03 20:03:48 -07:00
README.md Changes wasm middleware and output binding config to url instead of path (#2817) 2023-05-02 00:48:01 +00:00
benchmark_test.go Update go -> 1.24.1 & golangci-lint -> 1.64.6 (#3699) 2025-03-12 13:50:32 -07:00
httpwasm.go Rename folder "internal" to "common" (#3225) 2023-11-14 11:36:38 -08:00
httpwasm_test.go Update go -> 1.24.1 & golangci-lint -> 1.64.6 (#3699) 2025-03-12 13:50:32 -07:00

README.md

WebAssembly Middleware

This component lets you manipulate an incoming request or serve a response with custom logic compiled using the htp-wasm Application Binary Interface (ABI). The handle_request function receives an incoming request and can manipulate it or serve a response as necessary.

Please see the documentation for general configuration.

Generating Wasm

To compile your wasm, you must compile source using an SDK such as http-wasm-guest-tinygo. You can also make a copy of hello.go and replace the handler.HandleFn function with your custom logic.

If using TinyGo, compile like so and set the url attribute to "file://router.wasm":

tinygo build -o router.wasm -scheduler=none --no-debug -target=wasi router.go`

Notes

  • This is an alpha feature, so configuration is subject to change.
  • This module implements the host side of the http-wasm handler protocol.
  • This uses wazero for the WebAssembly runtime as it has no dependencies, nor relies on CGO. This allows installation without shared libraries.
  • Many WebAssembly compilers leave memory unbounded and/or set to 16MB. To avoid resource exhaustion, assign concurrency controls.