dataplaneapi
dataplaneapi copied to clipboard
Add a new HTTP Request Rule not checking if exists already
Hello,
I'm not sure if I'm doing something wrong but "POST /services/haproxy/configuration/http_request_rules" does not check if the rule already exists and keep doubling it...
I need to add: http-request set-header X-Forwarded-Proto https into specific backend.
The whole process looks like this:
- create the backed using version at the end of the call ( for some reason, I can't create a transaction where I create backend and add stuff into it... )
- create transaction and get ID
- add the header.
curl -X POST --user admin:admin \
-H "Content-Type: application/json" \
-d '{"type": "set-header", "index": 0, "hdr_name": "X-Forwarded-Proto https"}' \
"http://localhost:5555/v2/services/haproxy/configuration/http_request_rules?parent_type=backend&parent_name=some_backend&transaction_id=6835c700-f04e-4070-bbbc-2e970861ab45"
- add server to backend ( this does not duplicate, so its ok )
- commit the transaction.
Run it multiple time and the backend does not get duplicated, the server in backend does not get duplicated... the header keeps multiplying...
backend some_backend
http-request set-header X-Forwarded-Proto https
http-request set-header X-Forwarded-Proto https
http-request set-header X-Forwarded-Proto https
server server1 127.0.0.1:443 check ssl verify none
Is this a bug, or am I doing it wrong. There is a ton of option for the "Add a new HTTP Request Rule" but no explanation what is what.
EDIT: I have tried also just adding version=
This is because a configuration with multiple same http-request lines can be actually valid. They are evaluated in the order they are stated, and sometimes you can have two same http-request rules but in different positions and the end result is different.