mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-25 10:31:01 +01:00
Updated Proxying (markdown)
30
Proxying.md
30
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")
|
||||
);
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user