2014-02-21 00:03:33 -06:00
|
|
|
#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)
|
|
|
|
[![NuGet](https://img.shields.io/nuget/v/Flurl.Http.svg?maxAge=3600)](https://www.nuget.org/packages/Flurl.Http/)
|
|
|
|
[![MyGet PreRelease](https://img.shields.io/myget/flurl/vpre/Flurl.Http.svg?maxAge=3600)](https://www.myget.org/feed/flurl/package/nuget/Flurl.Http)
|
2016-05-20 01:03:38 +03:00
|
|
|
|
2014-06-05 16:34:53 -05: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() {
|
2014-07-24 11:33:20 -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
|
2014-07-24 11:33:20 -05:00
|
|
|
await sut.CreatePersonAsync("Frank", "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).
|
|
|
|
|
2016-07-26 06:36:24 -05:00
|
|
|
For detailed documentation, please visit the [main site](http://tmenier.github.io/Flurl/).
|