Mockserver path regex with override forwarded request

78 views Asked by At

I'm trying to create a MockServer expectation with regex path, because the service I want to forward sends requests with multiple different paths to the same external application.

I also need to use httpOverrideForwardedRequest, because we only have one deployment of MockServer for multiple different countries (and multiple deployments of the external app), so the internal service adds the code of the brand to the path of the request, and MockServer then removes it.

The expectation however doesn't get matched, and I think it's because my implementation of the regex is wrong, but I can't find the solution to my exact problem in the documentation.

I should add the forwarding was working beforehand, before I tried to add regular expressions, but there were dozens of expectations and the readability was very low.

This is my current expectation, and when I check the MockServer dashboard, I see the request wasn't matched, because "path didn't match". The path of the incoming request is /internal-service/mw-pl/rest/settle and the path it's supposed to forward with is /rest/settle.

        "httpRequest": {
          "path": "/internal-service/mw-{brand}{path}"
        },
        "httpOverrideForwardedRequest": {
          "requestOverride": {
            "path": "${path}",
            "socketAddress": {
              "scheme": "HTTP",
              "host": "external-${brand}.app",
              "port": 1234
            }
          }
        }
0

There are 0 answers