|
| 1 | +# Copyright 2022 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +static_resources: |
| 16 | + listeners: |
| 17 | + address: |
| 18 | + socket_address: |
| 19 | + address: 0.0.0.0 |
| 20 | + port_value: 10000 |
| 21 | + filter_chains: |
| 22 | + - filters: |
| 23 | + - name: envoy.filters.network.http_connection_manager |
| 24 | + typed_config: |
| 25 | + "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager |
| 26 | + stat_prefix: ingress_http |
| 27 | + codec_type: AUTO |
| 28 | + route_config: |
| 29 | + name: local_routes |
| 30 | + virtual_hosts: |
| 31 | + - name: local_service |
| 32 | + domains: |
| 33 | + - "*" |
| 34 | + routes: |
| 35 | + - match: |
| 36 | + prefix: "/" |
| 37 | + direct_response: |
| 38 | + status: 200 |
| 39 | + body: |
| 40 | + inline_string: "Welcome, set the `x-custom-metadata` header to change the response!\n" |
| 41 | + http_filters: |
| 42 | + # Set uppercase metadata in Lua filter |
| 43 | + - name: envoy.filters.http.lua |
| 44 | + typed_config: |
| 45 | + "@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua |
| 46 | + default_source_code: |
| 47 | + inline_string: | |
| 48 | + function envoy_on_request(request_handle) |
| 49 | + local headers = request_handle:headers() |
| 50 | + local data = headers:get("x-custom-metadata") |
| 51 | +
|
| 52 | + if data then |
| 53 | + request_handle:streamInfo():dynamicMetadata():set("envoy.filters.http.lua", "uppercased-custom-metadata", string.upper(data)) |
| 54 | + end |
| 55 | +
|
| 56 | + request_handle:logInfo("Metadata set by lua filter") |
| 57 | + end |
| 58 | + # Read it from a WASM filter |
| 59 | + - name: envoy.filters.http.wasm |
| 60 | + typed_config: |
| 61 | + "@type": type.googleapis.com/udpa.type.v1.TypedStruct |
| 62 | + type_url: type.googleapis.com/envoy.extensions.filters.http.wasm.v3.Wasm |
| 63 | + value: |
| 64 | + config: |
| 65 | + name: "envoy_metadata_filter" |
| 66 | + vm_config: |
| 67 | + runtime: "envoy.wasm.runtime.v8" |
| 68 | + code: |
| 69 | + local: |
| 70 | + filename: "/etc/envoy/proxy-wasm-plugins/proxy_wasm_example_envoy_filter_metadata.wasm" |
| 71 | + - name: envoy.filters.http.router |
| 72 | + typed_config: |
| 73 | + "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router |
0 commit comments