|
83 | 83 | } |
84 | 84 |
|
85 | 85 | $http_edge_rules_all = Hash($http_edge_rules_all_placeholder) |
| 86 | + # Filter undef fields from the http-edge rules |
86 | 87 | $http_edge_rules_all_real_without_undef = $http_edge_rules_all.map |$key, $value| { |
87 | 88 | $real_rules = $value.filter |$rules| { $rules =~ NotUndef } |
88 | 89 | [$key, $real_rules] |
89 | 90 | } |
90 | 91 | $http_edge_rules_all_real = Hash($http_edge_rules_all_real_without_undef) |
91 | 92 |
|
| 93 | + # Insert additional http-edge rules that are service specific |
92 | 94 | if 'canonicals' in $http_edge_services or 'status410' in $http_edge_services { |
93 | | - $http_response_rules = $ducktape::haproxy::frontends[$http_edge_frontend]['options']['http-response'] |
94 | 95 | if 'canonicals' in $http_edge_services { |
95 | 96 | $http_edge_canonicals_rules_real = flatten($http_edge_rules_all_real['canonicals'], 'set-var(txn.canonical_custom) hdr(X-Canonical-Custom) if { hdr(X-Canonical-Custom) -m found }', 'del-header X-Canonical-Custom if { hdr(X-Canonical-Custom) -m found }') |
96 | | - $http_response_canonicals_rules_real = concat($http_response_rules, 'set-header link %[var(txn.canonical_custom)] if { var(txn.canonical_custom) -m found }') |
97 | | - } |
98 | | - if 'status410' in $http_edge_services { |
99 | | - $http_response_status410_rules_real = concat($http_response_rules, 'set-status 410 if { var(txn.status410) -m bool }') |
100 | 97 | } |
101 | | - if 'canonicals' in $http_edge_services and 'status410' in $http_edge_services { |
102 | | - $http_response_rules_real_placeholder = concat($http_response_canonicals_rules_real, $http_response_status410_rules_real) |
103 | | - $http_response_rules_real = unique($http_response_rules_real_placeholder) |
104 | | - } elsif 'canonicals' in $http_edge_services { |
105 | | - $http_response_rules_real = $http_response_canonicals_rules_real |
106 | | - } else { |
107 | | - $http_response_rules_real = $http_response_status410_rules_real |
| 98 | + $http_response_rules = $ducktape::haproxy::frontends[$http_edge_frontend]['options']['http-response'] |
| 99 | + $http_response_new_rules = $http_edge_services.map | $service | { |
| 100 | + if $service == 'canonicals' { |
| 101 | + 'set-header link %[var(txn.canonical_custom)] if { var(txn.canonical_custom) -m found }' |
| 102 | + } elsif $service == 'canonicals' { |
| 103 | + 'set-status 410 if { var(txn.status410) -m bool }' |
| 104 | + } |
108 | 105 | } |
| 106 | + $http_response_new_rules_real = $http_response_rules.filter |$rules| { $rules =~ NotUndef } |
| 107 | + $http_response_rules_real = concat($http_response_rules, $http_response_new_rules_real) |
109 | 108 | $http_response_rules_hash = {$http_edge_frontend => {'options' => {'http-response' => $http_response_rules_real}}} |
110 | 109 | } |
111 | 110 |
|
112 | | - # Insert http-edge redirect rules at the marker position, or at the end if no marker |
| 111 | + # Insert http-edge rules at the marker position, or at the end if no marker |
113 | 112 | $http_request_rules = $ducktape::haproxy::frontends[$http_edge_frontend]['options']['http-request'] |
114 | 113 | if 'redirects' in $http_edge_services and grep($http_request_rules, $http_edge_markers['redirects']) == [] { |
115 | 114 | $http_request_rules_with_redirects = concat($http_request_rules, $http_edge_rules_all_real['redirects']) |
|
0 commit comments