Sebastián Gómez
06/25/2024, 12:08 PM{
"id": "get_profiles_inventory",
"priority": 0,
"httpRequest": {
"method": "GET",
"path": "/profiles/{profileId}/inventory",
"pathParameters": {
"profileId": "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"
},
"queryStringParameters": {
"param1": [
"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"
]
}
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": [
"mynewhost.svc.cluster.local"
]
},
"secure": false
},
"requestModifier": {
"path": {
"regex": "/profiles/([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})/inventory",
"substitution": "/vNext/totally/different/path/profiles/$1/inventory"
}
}
}
}
So, this expectation is making MS work as a proxy redirecting the call to a new services with a new path. In this case, whenever there's a GET to /profiles/{profileId}/inventory, I want that request to be redirected to another host (mynewhost.svc.cluster.local) with also a different path, BUT mantaing in this case the profileId from the original path.
GET /profiles/f1ab4c06-6f9a-4d0d-958c-7718b4808f64/inventory => GET mynewhost.svc.cluster.local/vNext/totally/different/path/profiles/f1ab4c06-6f9a-4d0d-958c-7718b4808f64/inventoryIs that possible writing a stub in JSON? Thanks
Sebastián Gómez
06/25/2024, 12:24 PM{
"name": "inventory",
"request": {
"method": "GET",
"urlPathTemplate": "/profiles/{profileId}/inventory",
"pathParameters": {
"profileId": {
"matches": "[A-Za-z]*"
}
}
},
"response": {
"proxyBaseUrl": "<https://google.com/vNext/totally/different/path/profiles/{{> request.path.profileId }}/inventory",
"proxyUrlPrefixToRemove": "{{ request.path }}",
"transformers": [
"response-template"
]
}
}
When I curl to <http://example.com/profiles/thisisatest/inventory|example.com/profiles/thisisatest/inventory>
I get a response from google (expected because of my proxyBaseUrl
with the following message
<p><b>404.</b> <ins>That’s an error.</ins>
<p>The requested URL <code>/vNext/totally/different/path/profiles/thisisatest/inventory/profiles/thisisatest/inventory</code> was not found on this server. <ins>That’s all we know.</ins>So the redirection is being done as expected, and the profile is kept, BUT, the
proxyUrlPrefixToRemove
does not seem to be workingLee Turner
06/25/2024, 12:53 PMproxyBaseUrl
to <https://google.com/vNext/totally/different/path>
and then I think you can remove the proxyUrlPrefixToRemove
part of the stub json.
Then when you make a call to the stub it should use the base url specified in the proxy and the path of the matched stub to generate a url of <https://google.com/vNext/totally/different/path/profiles/thisisatest/inventory>
Sebastián Gómez
06/25/2024, 12:58 PM"proxyUrlPrefixToRemove": "{{ request.path }}"
Lee Turner
06/25/2024, 12:59 PM/profiles/thisisatest/inventory
Sebastián Gómez
06/25/2024, 2:26 PM{
"name": "inventory",
"request": {
"method": "GET",
"urlPathTemplate": "/v1/profiles/{profileId}/inventory",
"pathParameters": {
"profileId": {
"matches": "[A-Za-z]*"
}
}
},
"response": {
"proxyBaseUrl": "<https://google.com/vNext/totally/different/path/profiles/{{> request.path.profileId }}/inventory",
"proxyUrlPrefixToRemove": "{{ request.path }}",
"transformers": [
"response-template"
]
}
}
Please nptice the v1
at the begining of the original path... like I said, I cannot just concatenate paths togetherLee Turner
06/25/2024, 2:51 PM{
"name": "inventory",
"request": {
"method": "GET",
"urlPathTemplate": "/v1/profiles/{profileId}/inventory",
"pathParameters": {
"profileId": {
"matches": "[A-Za-z]*"
}
}
},
"response": {
"proxyBaseUrl": "<https://google.com/vNext/totally/different/path>",
"proxyUrlPrefixToRemove": "/v1",
"transformers": [
"response-template"
]
}
}
Similar to before but removing the /v1
prefix.
Sorry if I am still miss-understanding your requirementsSebastián Gómez
06/25/2024, 5:43 PM"proxyUrlPrefixToRemove": "{{ request.path }}"
would work... is this expected or is it a bug?Lee Turner
06/25/2024, 5:48 PMLee Turner
06/25/2024, 5:48 PM