MyNihongo.FluentHttp 1.0.1

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package MyNihongo.FluentHttp --version 1.0.1
NuGet\Install-Package MyNihongo.FluentHttp -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MyNihongo.FluentHttp" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MyNihongo.FluentHttp --version 1.0.1
#r "nuget: MyNihongo.FluentHttp, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MyNihongo.FluentHttp as a Cake Addin
#addin nuget:?package=MyNihongo.FluentHttp&version=1.0.1

// Install MyNihongo.FluentHttp as a Cake Tool
#tool nuget:?package=MyNihongo.FluentHttp&version=1.0.1

Version Nuget downloads

FluentHttp

Fluent wrapper around IHttpClientFactory
Install a NuGet package MyNihongo.FluentHttp.

Configuration

Add a section to IConfiguration

{
	"FluentHttp": {
		"BaseAddress": "https://jsonplaceholder.typicode.com",
		"NtlmEnabled": false
	} 
}

Register a service

using MyNihongo.FluentHttp;

services.AddFluentHttp();

HTTP methods

To optimize JSON serialization JsonTypeInfo<T> can be supplied for all methods. More info about these types here.
In further examples a variable IFluentHttp fluentHttp will be used.

GetJsonAsync

Gets a JSON stream.

[JsonSerializable(typeof(RecordContext[]))]
internal partial class RecordContext : JsonSerializerContext {}

public sealed record RecordContext
{
	public int Id { get; set; }
}

// Get the model
var models = await fluentHttp
	.AppendPathSegment("example")
	.GetJsonAsync(RecordContext.Default.RecordArray, ct);
PostJsonAsync

Posts a JSON model and gets the JSON response.

[JsonSerializable(typeof(Request))]
internal partial class RequestContext : JsonSerializerContext {}

[JsonSerializable(typeof(Response))]
internal partial class ResponseContext : JsonSerializerContext {}

var req = new Request
{
	Data = "example"
};

var response = await fluentHttp
	.AppendPathSegment("example")
	.PostJsonAsync(req, RequestContext.Default.Request, ResponseContext.Default.Response, ct);

Fluent extensions

Fluent extensions supply additional parameters for the main HTTP methods.

AppendPathSegment

Appends a new section to the request URI.

// get from https://jsonplaceholder.typicode.com/posts
var result = await fluentHttp
	.AppendPathSegment("posts")
	.GetJsonAsync<PostRecord>();
AppendPathSegments

Appends multiple sections to the request URI.

// get from https://jsonplaceholder.typicode.com/posts/1/comments
var result = await fluentHttp
	.AppendPathSegment("posts", "1", "comments")
	.GetJsonAsync<PostCommentRecord>();
WithHeader

Appends a header to the request.

var result = await fluentHttp
	.AppendPathSegment("posts")
	.WithHeader("my-header", "value")
	.GetJsonAsync<PostRecord>();
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.1.2 26,132 1/17/2023
1.1.1 40,367 12/26/2022
1.1.0 40,236 12/14/2022
1.0.6 14,766 10/2/2022
1.0.5 17,370 8/11/2022
1.0.4 39,612 3/19/2022
1.0.3 41,759 3/1/2022
1.0.2 2,598 2/26/2022
1.0.1 9,403 1/8/2022