envoy icon indicating copy to clipboard operation
envoy copied to clipboard

Allow to use `body_format` in direct_response

Open ldb opened this issue 6 months ago • 4 comments
trafficstars

I would like to request that format strings (config.core.v3.SubstitutionFormatString) be supported inside a direct_response action for the router.

Right now it is only possible to provide hardcoded constant strings (from various sources) as the body for a direct_response action. However, it would be nice to be able to compose a response body from metadata provided by previous filters for example.

The custom_response filter already supports this using the localResponsePolicy but it requires to add another filter to the filter chain which does not easily give the same granularity of being invoked only for certain routes.

ldb avatar May 14 '25 13:05 ldb

Makes sense to me. I would add that custom_response filter operates on the upstream responses, and I think you want to skip sending to the upstream altogether.

kyessenov avatar May 14 '25 17:05 kyessenov

Yes definitely.

ldb avatar May 15 '25 08:05 ldb

@ldb Contributions are welcome! You would need to extend the API for direct_response to accept a substitution format string, and then implement the logic. All the building blocks are there, so it's mostly getting it all wired in and tests.

kyessenov avatar May 15 '25 17:05 kyessenov

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jun 14 '25 20:06 github-actions[bot]

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.

github-actions[bot] avatar Jun 22 '25 00:06 github-actions[bot]

@kyessenov @mattklein123, is there interest in this this being re-opened? I would like to contribute this change and it's my motivation to learn C++ and dive deeper into envoy.

ldb avatar Aug 06 '25 13:08 ldb