HttUnicorn 0.1.0
dotnet add package HttUnicorn --version 0.1.0
NuGet\Install-Package HttUnicorn -Version 0.1.0
<PackageReference Include="HttUnicorn" Version="0.1.0" />
paket add HttUnicorn --version 0.1.0
#r "nuget: HttUnicorn, 0.1.0"
// Install HttUnicorn as a Cake Addin #addin nuget:?package=HttUnicorn&version=0.1.0 // Install HttUnicorn as a Cake Tool #tool nuget:?package=HttUnicorn&version=0.1.0
HttUnicorn v0.1.0
Designed to help C# programmers creating HTTP Requests, this is The Hypertext Transfer Unicorn 🦄
Usage
Nuget
You can get HttpUnicorn by installing our NuGet Package;
Config
HttUnicorn uses a config object called UnicornConfig that need a string with the url.
var config = new UnicornConfig("http://localhost:3000/todos/");
You can also use UnicornConfig to set the Timeout and Headers
var config = new UnicornConfig(
"http://localhost:3000/todos/",
timeout: new TimeSpan(0, 0, 45),
headers: new List<UnicornHeader>(
new UnicornHeader("header_name", "header_value"),
new UnicornHeader("other_header_name", "other_header_value")
));
You can pass the timeout directly as seconds
var config = new UnicornConfig(
"http://localhost:3000/todos/",
timeoutSeconds: 35
);
You can start following the examples bellow:
Get
List<Todo> todos = await new Unicorn(config).GetModelAsync<List<Todo>>();
string todosString = await new Unicorn(config).GetStringAsync();
using(HttpResponseMessage responseMessage =
await new Unicorn(config).GetResponsegAsync())
{
//deal with the response message
}
Post
Todo generatedTodo = await new Unicorn(config)
.PostModelAsync<Todo, Todo>(new Todo
{
Completed = true,
Title = "todo",
UserId = 36
});
string stringResponseBody = await new Unicorn(config)
.PostStringAsync(new Todo
{
Completed = true,
Title = "todo",
UserId = 36
});
using(HttpResponseMessage responseMessage =
await new Unicorn(config).PostResponsegAsync())
{
//deal with the response message
}
Put
Todo updatedTodo = await new Unicorn(config)
.PutModelAsync<Todo, Todo>(todo);
Delete
MyApiResponse response = await new new Unicorn(config)
.DeleteModelAsync<MyApiResponse>(key);
//This one is for situations when the requested API returns an object in the body of the response.
Contact us
Tyler Mendes de Brito - @tylerbryto (Github) – colorigotica (Twitter) – tyler.brito99@gmail.com
Contributing
See git flow cheatsheet.
- Fork it (https://github.com/tylerbryto/httunicorn/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request
- Wait for our response
🦄
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.1 is compatible. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
-
.NETCoreApp 2.1
- Newtonsoft.Json (>= 11.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.1.0 | 836 | 11/15/2018 |
0.0.2-alfa | 589 | 10/14/2018 |
Migrated to dotnet core