Пример #1
0
        public override async Task InitializeAsync()
        {
            _upstreamServer = UpstreamBuilder
                              .UseKestrel()
                              .UseUrls("http://*:0")
                              .Build();
            await _upstreamServer.StartAsync();

            var port = _upstreamServer.GetServerPort();

            _proxyServer = ProxyBuilder
                           .UseKestrel()
                           .UseUrls("http://*:0")
                           .UseSetting("port", port.ToString())
                           .ConfigureTestServices(services =>
            {
                services
                .AddProxy(httpClientBuilder => httpClientBuilder
                          .ConfigureHttpClient(client => client.Timeout = TimeSpan.FromSeconds(1)));
            })
                           .Build();

            await _proxyServer.StartAsync();
        }