wasm

package
v1.13.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 14 Imported by: 1

README

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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMiddleware

func NewMiddleware(logger logger.Logger) dapr.Middleware

Types

type Metadata added in v1.12.0

type Metadata struct {
	// GuestConfig is an optional configuration passed to WASM guests.
	// Users can pass an arbitrary string to be parsed by the guest code.
	GuestConfig string `mapstructure:"guestConfig"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL