Skip to content

BackendTrafficPolicy responseOverride support request header matching #8608

@sjoukedv

Description

@sjoukedv

Description:

Currently, we only support statusCode matching, e.g.

  responseOverride:
    - match:
        statusCodes:
          - type: Range
            range:
              start: 500
              end: 599
          - type: Value
            value: 403
      response:
        contentType: text/html
        header:
          set:
         # some extra header
          - name: x-envoy-custom-error
            value: custom-500-page

        # or user-friendly body
        body:
          type: ValueRef
          valueRef:
            group: ""
            kind: ConfigMap
            name: my-dynamic-error-template

It would be great if we also support the Accept request header so that we can return custom JSON for API routes, but keep the html page for request that are rendered in the browser.

This is something that was present in ingress-nginx

A custom error backend can use this information to return the best possible representation of an error page. For example, if the value of the Accept header send by the client was application/json, a carefully crafted backend could decide to return the error payload as a JSON document instead of HTML.

[optional Relevant Links:]

https://gateway.envoyproxy.io/docs/api/extension_types/#customresponsematch

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions