Handle params per body layer
@@ -441,11 +441,10 @@ func (p *Proxy) SetRoundtripContext(req *http.Request, beresp *http.Response) {
if attrOk && req != nil && beresp == nil { // just one way -> origin
values := req.URL.Query()
- for _, attrs := range allAttributes.JustAllAttributesWithName(attrDelQueryParams) {
+ // not by name to ensure the order for all params
+ for _, attrs := range allAttributes.JustAllAttributes() {
attr, ok := attrs[attrDelQueryParams]
- if !ok {
- continue
- }
+ if ok {
val, diags := attr.Expr.Value(evalCtx)
if seetie.SetSeverityLevel(diags).HasErrors() {
p.log.WithField("parse config", p.String()).Error(diags)
@@ -455,22 +454,24 @@ func (p *Proxy) SetRoundtripContext(req *http.Request, beresp *http.Response) {
}
}
- for _, name := range []string{attrSetQueryParams, attrAddQueryParams} {
- for _, attrs := range allAttributes.JustAllAttributesWithName(name) {
- attr, ok := attrs[name]
- if !ok {
- continue
- }
+ attr, ok = attrs[attrSetQueryParams]
+ if ok {
options, diags := NewOptionsMap(evalCtx, attr)
if diags != nil {
p.log.WithField("parse config", p.String()).Error(diags)
}
for k, v := range options {
- if name == attrSetQueryParams {
values[k] = v
- continue
}
- // add
+ }
+
+ attr, ok = attrs[attrAddQueryParams]
+ if ok {
+ options, diags := NewOptionsMap(evalCtx, attr)
+ if diags != nil {
+ p.log.WithField("parse config", p.String()).Error(diags)
+ }
+ for k, v := range options {
if _, ok = values[k]; !ok {
values[k] = v
} else {
@@ -479,6 +480,7 @@ func (p *Proxy) SetRoundtripContext(req *http.Request, beresp *http.Response) {
}
}
}
+
req.URL.RawQuery = values.Encode()
}
