WireMock.Net icon indicating copy to clipboard operation
WireMock.Net copied to clipboard

Proxy - Remove prefix

Open lillo42 opened this issue 4 years ago • 1 comments

Hi,

Is there any way where I can remove an prefix from route before proxy it?

GIVEN The following code will proxy all GET requests made to http://:/other/service/.* to http://otherservice.com/approot And proxyUrlPrefixToRemove transformation parameter is set to "/other/service" WHEN running WireMock locally a request to http://localhost:8080/other/service/doc/123 THEN it would be forwarded to http://otherservice.com/approot/doc/123

Wiremock: https://github.com/tomakehurst/wiremock/issues/745 Workaround: https://gist.github.com/pavetok/62f7f0e315fcadeeae9bfcb1f8de54ad

lillo42 avatar Aug 26 '21 15:08 lillo42

Hello @lillo42 ,

I think this can be added to WireMock.Net, like adding a new property

    "Replace" : {
        "OldValue": "/other/service",
        "NewValue": ""
    }

to https://github.com/WireMock-Net/WireMock.Net/blob/dc078b57ea463e2c9c7da7f6579af34000596446/src/WireMock.Net/Settings/ProxyAndRecordSettings.cs

StefH avatar Oct 24 '21 08:10 StefH

@lillo42 Is this answer clear enough?

StefH avatar Nov 07 '22 19:11 StefH

@StefH I have raised a pull request that aims to implement your suggestion above. https://github.com/WireMock-Net/WireMock.Net/pull/924

nudejustin avatar Apr 19 '23 10:04 nudejustin