Flurl is a modern, fluent, asynchronous, testable, portable, buzzword-laden URL builder and HTTP client library for .NET.☍
Code It
// Flurl will use 1 HttpClient instance per host
var person = await "https://api.com"
.AppendPathSegment("person")
.SetQueryParams(new { a = 1, b = 2 })
.WithOAuthBearerToken("my_oauth_token")
.PostJsonAsync(new
{
first_name = "Claire",
last_name = "Underwood"
})
.ReceiveJson<Person>();
Test It
// fake & record all http calls in the test subject
using (var httpTest = new HttpTest()) {
// arrange
httpTest.RespondWith("OK", 200);
// act
await sut.CreatePersonAsync();
// assert
httpTest.ShouldHaveCalled("https://api.com/*")
.WithVerb(HttpMethod.Post)
.WithContentType("application/json");
}
Flurl is available on NuGet. It is free for commercial use and runs everywhere .NET runs.☍
Get It
For just the URL builder, install Flurl. For everything else, install Flurl.Http.
Learn It
You've come to the right place. Check out the docs.
Report an Issue
To report a bug or request a feature, open an issue on GitHub.
Stay Informed
To stay current on releases and other announcements, follow @FlurlHttp.