Skip to content

Latest commit

 

History

History
59 lines (42 loc) · 2.57 KB

README.md

File metadata and controls

59 lines (42 loc) · 2.57 KB

MicroElements.FluentProxy

Simple http proxy to use in front of real services. Use it for tracing blackboxes and for mocking responses.

WARNING: version before 1.0.0 has unstable API. After stabilizing this warning will be removed!

Statuses

License NuGetVersion NuGetDownloads MyGetVersion

Travis AppVeyor Coverage Status

Gitter

Installation

Package Reference:

dotnet add package MicroElements.FluentProxy

Usage

var settings = new FluentProxySettings
{
    ExternalUrl = new Uri("https://api.github.com"),
    OnRequestFinished = session =>
    {
        Console.WriteLine(session.RequestUrl);
        Console.WriteLine(session.ResponseData.ResponseContent);
    }
};
FluentProxyServer fluentProxyServer = await FluentProxyFactory.CreateServer(settings);

var request = new HttpRequestMessage(HttpMethod.Get, "/repos/aspnet/docs/branches");
request.Headers.Add("Accept", "application/vnd.github.v3+json");
request.Headers.Add("User-Agent", "HttpClientFactory-Sample");

HttpClient httpClient = fluentProxyServer.GetHttpClient();

var httpResponseMessage = await httpClient.SendAsync(request);
var response = await httpResponseMessage.Content.ReadAsStringAsync();

Build

Windows: Run build.ps1

Linux: Run build.sh

License

This project is licensed under the MIT license. See the LICENSE file for more info.