DirectResponse
DirectResponse is a Gwin custom resource that instructs the load balancer to return a fixed HTTP response directly to the client, without forwarding the request to any backend service.
It is referenced from an HTTPRoute rule via an ExtensionRef filter. This makes it conceptually similar to RequestRedirect — both are terminal route actions that short-circuit normal backend routing.
Typical use cases: returning 404 Not Found for unknown paths, 503 Service Unavailable during maintenance, or any other static response.
Cheatsheet
apiVersion: gwin.yandex.cloud/v1
kind: DirectResponse
metadata:
name: not-found-response
namespace: example-ns
spec:
responseCode: 404 # HTTP status code to return
responseBody:
text: "Path not found" # optional plain-text body
Reference from an HTTPRoute rule via ExtensionRef filter:
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: example-route
namespace: example-ns
spec:
parentRefs:
- name: example-gateway
rules:
- matches:
- path:
type: PathPrefix
value: /unknown
filters:
- type: ExtensionRef
extensionRef:
group: gwin.yandex.cloud
kind: DirectResponse
name: not-found-response # must be in the same namespace as the HTTPRoute
Примечание
A rule that uses a DirectResponse filter must not include backendRefs — the direct response replaces normal backend routing entirely.
| Field | Description |
|---|---|
| metadata | ObjectMeta Standard Kubernetes metadata. |
| spec | DirectResponseSpec Direct response specification. |
DirectResponseSpec
DirectResponseSpec defines the HTTP response to be returned to the client.
Appears in: DirectResponse
| Field | Description |
|---|---|
| responseCode | integer HTTP status code to return. Example: 404, 503. |
| responseBody | DirectResponseBody Optional response body. If omitted, the response has an empty body. |
DirectResponseBody
DirectResponseBody defines the plain-text content of the response body.
Appears in: DirectResponseSpec
| Field | Description |
|---|---|
| text | string Plain-text body content. Example: Path not found |