Skip to content

Feature Request: In lua http filter add ability to set the contents of the body #5998

@DevoKun

Description

@DevoKun

Feature Request: In lua http filter add ability to set the contents of the body

The idea is to be able to set the contents of the response body from lua.
This feature is helpful for providing a custom response in the event of an upstream failure.
For example, if a circuit breaker fails for an API that is expected to be JSON, a response of an empty json array could [] be returned instead of the message upstream connect error or disconnect/reset before headers. reset reason: connection failure which would break an app expecting JSON.

filter_chains:
- filters:
  - name: envoy.http_connection_manager
    config:
      http_filters:
        - name: envoy.lua
          config:
            inline_code: |
              function envoy_on_response(response_handle)
                if response_handle:headers():get(":status") != "200" then
                  response_handle:body():set('[]')
                end
              end

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature requests. Not bugs or questions.help wantedNeeds help!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions