http_headers

command module
v0.0.0-...-228bf11 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

README

http_headers

This example handles http request/response headers events and log all headers.

In envoy.yaml, the custom header is given as the plugin configuration like the following:

configuration:
  "@type": type.googleapis.com/google.protobuf.StringValue
  value: |
    {
      "header": "x-wasm-header",
      "value": "demo-wasm"
    }

and this adds the x-wasm-header: demo-wasm header to all the responses. Also, it adds a hardcoded header "x-proxy-wasm-go-sdk-example" with value "http_headers".

wasm log: request header --> :authority: localhost:18000
wasm log: request header --> :path: /uuid
wasm log: request header --> :method: GET
wasm log: request header --> user-agent: curl/7.68.0
wasm log: request header --> accept: */*
wasm log: request header --> x-forwarded-proto: http
wasm log: request header --> x-request-id: 5692b633-fd9c-4700-b4dd-7a58e2853eb4
wasm log: response header <-- :status: 200
wasm log: response header <-- content-length: 13
wasm log: response header <-- content-type: text/plain
wasm log: response header <-- date: Thu, 01 Oct 2020 09:10:09 GMT
wasm log: response header <-- server: envoy
wasm log: response header <-- x-envoy-upstream-service-time: 0
wasm log: response header --> x-proxy-wasm-go-sdk-example: http_headers
wasm log: response header --> x-wasm-header: demo-wasm
wasm log: 2 finished

build

CGO_ENABLED=0 tinygo build -o http_headers.wasm -scheduler=asyncify -tags=appengine -target=wasi main.go

Documentation

Overview

Copyright 2020-2021 Tetrate

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

There are four types of these interfaces which you are supposed to implement in order to extend your network proxies. They are VMContext, PluginContext, TcpContext and HttpContext, and their relationship can be described as the following diagram:

                        Wasm Virtual Machine(VM)
                   (corresponds to VM configuration)
┌────────────────────────────────────────────────────────────────────────────┐
│                                                      TcpContext            │
│                                                  ╱ (Each Tcp stream)       │
│                                                 ╱                          │
│                      1: N                      ╱ 1: N                      │
│       VMContext  ──────────  PluginContext                                 │
│  (VM configuration)     (Plugin configuration) ╲ 1: N                      │
│                                                 ╲                          │
│                                                  ╲   HttpContext           │
│                                                   (Each Http stream)       │
└────────────────────────────────────────────────────────────────────────────┘

Directories

Path Synopsis
adapters

Jump to

Keyboard shortcuts

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