From bc1d000c0a0699f99141108b68198ce56182e4bc Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Thu, 7 Nov 2019 08:45:22 +0100 Subject: [PATCH] Updated Proxying (markdown) --- Proxying.md | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/Proxying.md b/Proxying.md index b4cb81a..6ee5d14 100644 --- a/Proxying.md +++ b/Proxying.md @@ -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") ); -``` - +```