From d3dfc9a7022643596ed0d0a24b1b281715c773e0 Mon Sep 17 00:00:00 2001 From: Loong Dai Date: Sat, 25 Jun 2022 01:43:28 +0800 Subject: [PATCH] add wasm http middleware (#2520) * add wasm http middleware Signed-off-by: Loong Dai * Update daprdocs/content/en/reference/components-reference/supported-middleware/_index.md Co-authored-by: Mark Fussell * Update daprdocs/content/en/reference/components-reference/supported-middleware/middleware-wasm.md Co-authored-by: Mark Fussell * Update daprdocs/content/en/reference/components-reference/supported-middleware/middleware-wasm.md Co-authored-by: Mark Fussell * Update daprdocs/content/en/reference/components-reference/supported-middleware/middleware-wasm.md Co-authored-by: Mark Fussell * Update daprdocs/content/en/reference/components-reference/supported-middleware/middleware-wasm.md Co-authored-by: Mark Fussell * Update daprdocs/content/en/reference/components-reference/supported-middleware/middleware-wasm.md Co-authored-by: Mark Fussell * Update daprdocs/content/en/reference/components-reference/supported-middleware/middleware-wasm.md Co-authored-by: Mark Fussell * Update middleware-wasm.md * Update middleware-wasm.md * Update middleware-wasm.md * Update middleware-wasm.md * Update middleware-wasm.md * Update _index.md Co-authored-by: Yaron Schneider Co-authored-by: Mark Fussell --- .../supported-middleware/middleware-wasm.md | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 daprdocs/content/en/reference/components-reference/supported-middleware/middleware-wasm.md diff --git a/daprdocs/content/en/reference/components-reference/supported-middleware/middleware-wasm.md b/daprdocs/content/en/reference/components-reference/supported-middleware/middleware-wasm.md new file mode 100644 index 00000000000..6ee2d58d0fe --- /dev/null +++ b/daprdocs/content/en/reference/components-reference/supported-middleware/middleware-wasm.md @@ -0,0 +1,61 @@ +--- +type: docs +title: "WASM" +linkTitle: "WASM" +description: "Use WASM middleware in your HTTP pipeline" +aliases: +- /developing-applications/middleware/supported-middleware/middleware-wasm/ +--- + +The WASM [HTTP middleware]({{< ref middleware.md >}}) component enables you to use a WASM module to handle requests and responses. +Using WASM modules allow developers to write middleware components in any WASM supported language and extend Dapr using external files that are not pre-compiled into the `daprd` binary. + +WASM modules are loaded from a filesystem path. On Kubernetes, see [mounting volumes to the Dapr sidecar]({{> kubernetes-volume-mounts.md >}}) to configure a filesystem mount that can contain WASM modules. + +## Component format + + +```yaml +apiVersion: dapr.io/v1alpha1 +kind: Component +metadata: + name: wasm +spec: + type: middleware.http.wasm.basic + version: v1 + metadata: + - name: path + value: "./hello.wasm" + - name: runtime + value: "wazero" +``` + +## Spec metadata fields + +| Field | Details | Example | +|-------|---------|---------| +| path | A relative or absolute path to the WASM module | "./hello.wasm" | +| runtime | The WASM runtime of your WASM binary. Only `wazero` is supported | ["wazero"](https://github.com/tetratelabs/wazero) | + + +## Dapr configuration + +To be applied, the middleware must be referenced in [configuration]({{< ref configuration-concept.md >}}). See [middleware pipelines]({{< ref "middleware.md#customize-processing-pipeline">}}). + +```yaml +apiVersion: dapr.io/v1alpha1 +kind: Configuration +metadata: + name: appconfig +spec: + httpPipeline: + handlers: + - name: wasm + type: middleware.http.wasm.basic +``` + +## Related links + +- [Middleware]({{< ref middleware.md >}}) +- [Configuration concept]({{< ref configuration-concept.md >}}) +- [Configuration overview]({{< ref configuration-overview.md >}})