Updated Proxying (markdown)

Stef Heyenrath
2019-11-07 08:45:22 +01:00
parent 2fc4197266
commit bc1d000c0a

@@ -1,3 +1,30 @@
# Global Proxy
It's possible to start the WireMockk server in Proxy mode, this means that all requests are proxied to the real URL. And the mappings can be recorded and saved.
### Example
Setup a proxy to samples.openweathermap.org
``` c#
var settings = new FluentMockServerSettings
{
Urls = new[] { "https://localhost:9095/" },
StartAdminInterface = true,
ProxyAndRecordSettings = new ProxyAndRecordSettings
{
Url = "https://samples.openweathermap.org",
SaveMapping = true,
SaveMappingToFile = true,
SaveMappingForStatusCodePattern = "2xx"
}
};
var server = FluentMockServer.Start(settings);
```
You can now call (via an httpclient or just in browser) this URL: `https://localhost:9095/data/2.5/find?q=London&units=metric&appid=b6907d289e10d714a6e88b30761fae22`
See also this [proxyandrecordsettings](https://github.com/WireMock-Net/WireMock.Net/wiki/Settings#proxyandrecordsettings)
# Proxy stub mappings
Proxy responses are defined in exactly the same manner as stubs, meaning that the same request matching criteria can be used.
@@ -67,6 +94,5 @@ server
.WithStatusCode(503)
.WithBody("ERROR")
);
```
```