3

I'm using a wiremock server onto which I configure mappings using the rest API (via JSON mappings). For some APIs, I have specific mocks based on a value inside the body of the request and I want to add another mapping to proxy requests to the real service when conditions in body are not met as a fallback.

This can be done by a mapping like that: (Priority = 500 is to be sure that specific mappings have a higher priority, and this one should only be used as a fallback) :

{
  "priority": 500,
  "request": {
    "method": "POST",
    "urlPattern": "/my/service"
  },
  "response": {
    "proxyBaseUrl": "http://real-server"
  }
}

The problem is: I don't want to have the "real-server" hardcoded in the mapping, I need it to be a dynamic value. To achieve this I wanted to use the environment variable but didn't manage to make it work.

I thought something like that should do the trick. The problem is: that I can save the mapping but as soon as I call the URL on wiremock I get a 500 error telling me that there is an illegal character in authority

{
  "priority": 500,
  "request": {
    "method": "POST",
    "urlPattern": "/my/service"
  },
  "response": {
    "proxyBaseUrl": "http://{{systemValue type='ENVIRONMENT' key='REAL_SERVER_NAME'}}"
  }
}

I suppose I'm doing something wrong but I don't know what.

If someone already faced this problem, I'll be happy to have a little help.

Thanks!

Julien O
  • 171
  • 2
  • 11

0 Answers0