config: only validate redirect response code when non-nil

This commit is contained in:
Joe Kralicky 2024-11-05 15:44:41 -05:00
parent 526e2a58d6
commit a5d4acc7b4
No known key found for this signature in database
GPG key ID: 75C4875F34A9FB79

View file

@ -233,12 +233,10 @@ func (r *PolicyRedirect) validate() error {
// GetEnvoyResponseCode returns the ResponseCode as the corresponding Envoy enum value.
func (r *PolicyRedirect) GetEnvoyResponseCode() (envoy_config_route_v3.RedirectAction_RedirectResponseCode, error) {
var code int32
if r != nil && r.ResponseCode != nil {
code = *r.ResponseCode
if r == nil || r.ResponseCode == nil {
return envoy_config_route_v3.RedirectAction_RedirectResponseCode(0), nil
}
switch code {
switch code := *r.ResponseCode; code {
case http.StatusMovedPermanently:
return envoy_config_route_v3.RedirectAction_MOVED_PERMANENTLY, nil
case http.StatusFound: