Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metadata example #289

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Add metadata example #289

wants to merge 3 commits into from

Conversation

Swaagie
Copy link
Contributor

@Swaagie Swaagie commented Nov 4, 2024

fixes #288. Happy to adjust this to where it has the most value/clear use cases.

@Swaagie Swaagie force-pushed the metadata-example branch 2 times, most recently from e5f9a4a to 4077239 Compare November 4, 2024 12:07
Signed-off-by: Martijn Swaagman <martijn@swaagman.online>
Signed-off-by: Martijn Swaagman <martijn@swaagman.online>
Signed-off-by: Martijn Swaagman <martijn@swaagman.online>
body:
inline_string: "Welcome, set the `x-custom-metadata` header to change the response!\n"
http_filters:
# Set metadata
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Set metadata in Lua filter

local data = headers:get("x-custom-metadata")

if data then
request_handle:streamInfo():dynamicMetadata():set("envoy.filters.http.lua", "x-custom-metadata", data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking, but it would be slightly more realistic and easier to understand the flow if:

  1. Lua did something with the input (e.g. convert to uppercase),
  2. Metadata key would be different from the HTTP header name.

@@ -22,6 +22,7 @@
- [HTTP Response body](./examples/http_body/)
- [HTTP Configuration](./examples/http_config/)
- [gRPC Auth (random)](./examples/grpc_auth_random/)
- [Filter metadata](./examples/filter_metadata/)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename this to Envoy filter metadata to make it clear that it's Envoy-specific feature (here and everywhere else throughout this PR)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide an example to read metadata set by other filters
2 participants