Skip to content

Commit

Permalink
DirectResponse
Browse files Browse the repository at this point in the history
Signed-off-by: zirain <zirain2009@gmail.com>
  • Loading branch information
zirain committed May 13, 2024
1 parent df0af7c commit 115fdb1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/gatewayapi/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,8 @@ func (t *Translator) processGRPCRouteRules(grpcRoute *GRPCRouteContext, parentRe

// If the route has no valid backends then just use a direct response and don't fuss with weighted responses
for _, ruleRoute := range ruleRoutes {
if ruleRoute.Destination == nil && ruleRoute.Redirect == nil {
noValidBackends := ruleRoute.Destination == nil || ruleRoute.Destination.ToBackendWeights().Valid == 0
if noValidBackends && ruleRoute.Redirect == nil {
ruleRoute.DirectResponse = &ir.DirectResponse{
StatusCode: 500,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,8 @@ xdsIR:
name: grpcroute/envoy-gateway/grpcroute-1/rule/0
settings:
- weight: 1
directResponse:
statusCode: 500
headerMatches:
- distinct: false
exact: foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,8 @@ xdsIR:
name: grpcroute/envoy-gateway/grpcroute-1/rule/0
settings:
- weight: 1
directResponse:
statusCode: 500
headerMatches:
- distinct: false
exact: foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ xdsIR:
name: grpcroute/envoy-gateway/grpcroute-1/rule/0
settings:
- weight: 1
directResponse:
statusCode: 500
headerMatches:
- distinct: false
exact: foo
Expand Down

0 comments on commit 115fdb1

Please sign in to comment.