Exemplo n.º 1
0
        private async Task UpdateServiceExtensions(ProxyItem item)
        {
            var exists = SplitTesting.ServiceExtensions.TryGetValue(item.Key, out ProxyItem res);

            if (exists)
            {
                SplitTesting.ServiceExtensions.Remove(item.Key);
            }
            SplitTesting.ServiceExtensions.Add(item.Key, item);
        }
Exemplo n.º 2
0
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            // root
            if (request.RequestUri.PathAndQuery == "/")
            {
                return(await GetRoot());
            }

            // proxy
            if (request.RequestUri.PathAndQuery == "/proxy" && request.Method == HttpMethod.Post)
            {
                string    json      = request.Content.ReadAsStringAsync().Result;
                ProxyItem proxyItem = JsonConvert.DeserializeObject <ProxyItem>(json);
                await UpdateServiceExtensions(proxyItem);
            }

            return(await RedirectRequest(request, cancellationToken));
        }