Flurl/README.md

46 lines
1.6 KiB
Markdown
Raw Normal View History

# Flurl
2014-02-16 15:43:15 -08:00
2016-07-26 21:03:18 +03:00
[![Build status](https://ci.appveyor.com/api/projects/status/hec8ioqg0j07ttg5/branch/master?svg=true)](https://ci.appveyor.com/project/kroniak/flurl/branch/master)
[![Flurl](https://img.shields.io/nuget/v/Flurl.svg?maxAge=3600)](https://www.nuget.org/packages/Flurl/)
[![Flurl.Http](https://img.shields.io/nuget/v/Flurl.Http.svg?maxAge=3600)](https://www.nuget.org/packages/Flurl.Http/)
2016-05-20 01:03:38 +03:00
Flurl is a modern, fluent, asynchronous, testable, portable, buzzword-laden URL builder and HTTP client library.
2014-05-04 14:26:01 -05:00
````c#
2014-07-24 11:33:20 -05:00
var result = await "https://api.mysite.com"
2014-05-04 14:26:01 -05:00
.AppendPathSegment("person")
2014-07-24 11:33:20 -05:00
.SetQueryParams(new { api_key = "xyz" })
.WithOAuthBearerToken("my_oauth_token")
.PostJsonAsync(new { first_name = firstName, last_name = lastName })
.ReceiveJson<T>();
2014-05-04 14:26:01 -05:00
[Test]
public void Can_Create_Person() {
2017-08-08 21:46:50 -05:00
// fake & record all http calls in the test subject
2014-05-04 14:26:01 -05:00
using (var httpTest = new HttpTest()) {
// arrange
httpTest.RespondWith(200, "OK");
// act
2018-06-25 13:10:32 -04:00
await sut.CreatePersonAsync("Claire", "Underwood");
2014-05-04 14:26:01 -05:00
// assert
httpTest.ShouldHaveCalled("http://api.mysite.com/*")
.WithVerb(HttpMethod.Post)
.WithContentType("application/json");
}
}
2014-02-21 00:03:33 -06:00
````
2014-05-04 14:26:01 -05:00
Get it on NuGet:
2014-02-21 00:03:33 -06:00
2014-05-04 14:26:01 -05:00
`PM> Install-Package Flurl.Http`
2014-02-21 00:03:33 -06:00
2014-05-04 14:26:01 -05:00
Or get just the stand-alone URL builder without the HTTP features:
2014-02-21 00:03:33 -06:00
2014-05-04 14:26:01 -05:00
`PM> Install-Package Flurl`
2014-02-21 00:03:33 -06:00
2014-12-06 10:10:29 -06:00
For updates and announcements, [follow @FlurlHttp on Twitter](https://twitter.com/intent/user?screen_name=FlurlHttp).
2018-06-14 22:53:25 -05:00
For detailed documentation, please visit the [main site](https://flurl.io).