Skip to content

Commit 24dd22c

Browse files
committed
chore: implement suggestion
Signed-off-by: Martijn Swaagman <[email protected]>
1 parent f8d4b2f commit 24dd22c

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
- [HTTP Response body](./examples/http_body/)
2323
- [HTTP Configuration](./examples/http_config/)
2424
- [gRPC Auth (random)](./examples/grpc_auth_random/)
25-
- [Filter metadata](./examples/filter_metadata/)
25+
- [Envoy filter metadata](./examples/envoy_filter_metadata/)
2626

2727
## Articles & blog posts from the community
2828

examples/filter_metadata/Cargo.toml renamed to examples/envoy_filter_metadata/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[package]
22
publish = false
3-
name = "proxy-wasm-example-filter-metadata"
3+
name = "proxy-wasm-example-envoy-filter-metadata"
44
version = "0.0.1"
55
authors = ["Martijn Swaagma <[email protected]>"]
6-
description = "Proxy-Wasm plugin example: Filter metadata"
6+
description = "Proxy-Wasm plugin example: Envoy filter metadata"
77
license = "Apache-2.0"
88
edition = "2018"
99

examples/filter_metadata/README.md renamed to examples/envoy_filter_metadata/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## Proxy-Wasm plugin example: Metadata
1+
## Proxy-Wasm plugin example: Envoy metadata
22

3-
Proxy-Wasm plugin that demonstrates reading metadata set by other filters
3+
Proxy-Wasm plugin that demonstrates reading metadata set by other Envoy filters
44

55
### Building
66

@@ -24,10 +24,10 @@ $ curl localhost:10000/
2424
Welcome, set the `x-custom-metadata` header to change the response!
2525
```
2626

27-
28-
Send a HTTP request to `localhost:10000/` with a `x-custom-metadata` header value.
27+
Send a HTTP request to `localhost:10000/` with a `x-custom-metadata` header value to get the uppercased value in the response.
28+
The response will also set a response header `uppercased-metadata: SOME-VALUE`.
2929

3030
```sh
3131
$ curl localhost:10000/ -H "x-custom-metadata: some-value"
32-
Custom response with `x-custom-metadata` value "some-value"
32+
Custom response with Envoy metadata: "SOME-VALUE"!
3333
```

examples/filter_metadata/envoy.yaml renamed to examples/envoy_filter_metadata/envoy.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static_resources:
3939
body:
4040
inline_string: "Welcome, set the `x-custom-metadata` header to change the response!\n"
4141
http_filters:
42-
# Set metadata
42+
# Set uppercase metadata in Lua filter
4343
- name: envoy.filters.http.lua
4444
typed_config:
4545
"@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
@@ -50,7 +50,7 @@ static_resources:
5050
local data = headers:get("x-custom-metadata")
5151
5252
if data then
53-
request_handle:streamInfo():dynamicMetadata():set("envoy.filters.http.lua", "x-custom-metadata", data)
53+
request_handle:streamInfo():dynamicMetadata():set("envoy.filters.http.lua", "uppercased-custom-metadata", string.upper(data))
5454
end
5555
5656
request_handle:logInfo("Metadata set by lua filter")
@@ -62,12 +62,12 @@ static_resources:
6262
type_url: type.googleapis.com/envoy.extensions.filters.http.wasm.v3.Wasm
6363
value:
6464
config:
65-
name: "metadata_filter"
65+
name: "envoy_metadata_filter"
6666
vm_config:
6767
runtime: "envoy.wasm.runtime.v8"
6868
code:
6969
local:
70-
filename: "/etc/envoy/proxy-wasm-plugins/proxy_wasm_example_filter_metadata.wasm"
70+
filename: "/etc/envoy/proxy-wasm-plugins/proxy_wasm_example_envoy_filter_metadata.wasm"
7171
- name: envoy.filters.http.router
7272
typed_config:
7373
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router

examples/filter_metadata/src/lib.rs renamed to examples/envoy_filter_metadata/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ impl HttpContext for MetadataHttp {
3131
"metadata",
3232
"filter_metadata",
3333
"envoy.filters.http.lua",
34-
"x-custom-metadata",
34+
"uppercased-custom-metadata",
3535
]) {
3636
Some(metadata) => match String::from_utf8(metadata) {
3737
Ok(data) => {
3838
self.send_http_response(
3939
200,
40-
vec![("Powered-By", "proxy-wasm")],
40+
vec![("Powered-By", "proxy-wasm"), ("uppercased-metadata", &data)],
4141
Some(
4242
format!(
43-
"Custom response with `x-custom-metadata` value {:?}!\n",
43+
"Custom response with Envoy metadata: {:?}!\n",
4444
data
4545
)
4646
.as_bytes(),

0 commit comments

Comments
 (0)