YAFLHttp 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package YAFLHttp --version 1.0.0
NuGet\Install-Package YAFLHttp -Version 1.0.0
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="YAFLHttp" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add YAFLHttp --version 1.0.0
#r "nuget: YAFLHttp, 1.0.0"
#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 YAFLHttp as a Cake Addin
#addin nuget:?package=YAFLHttp&version=1.0.0

// Install YAFLHttp as a Cake Tool
#tool nuget:?package=YAFLHttp&version=1.0.0

YAFLHttp

Yet Another Fluent Library for Http client (YAFLHttp) is a fluent API for working with HTTP client class that seeks to provide a simply and intuitive devloper experience

Installing YAFLHttp

You should install YAFLHttp with NuGet:

Install-Package YAFLHttp

Or via the .NET command line interface (.NET CLI):

dotnet add package YAFLHttp

Either commands, from Package Manager Console or .NET Core CLI, will allow download and installation of YAFLHttp and all its required dependencies.

How do I get started?

First, configure YAFLHttp by adding required http clients, in the startup of your application:

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddFluentHttp("identity-server", builder =>
{
    builder.WithTimeout(10);
}).AddFluentHttp<TodoController>(builder =>
 {
     builder.WithBaseUrl("https://localhost:18963/")
         .WithHeader("x-api-version", "1.0.0-beta")
         .AddFilter<TimerHttpClientFilter>()
         .WithTimeout(20)
         .Register();
 }).AddFluentHttp("file-upload", builder =>
 {
     builder.WithBaseUrl("https://localhost:18963/")
        .WithTimeout(TimeSpan.FromMinutes(2));
 });
//...

Inject the IFluentHttpClientFactory where you need to work with an HttpClient instance.

```csharp
public class TodoController : Controller
{
    private readonly IFluentHttpClientFactory _clientFactory;

    public TodoController(IFluentHttpClientFactory clientFactory)
    {
        _clientFactory = clientFactory;
    }

    public async Task<IActionResult> Index(int pageNo = 1, int pageSize = 10)
    {
        var client = _clientFactory.Get<TodoController>();
        var bearer = await GetAuthToken();

        var items = await client
          .Endpoint("/api/v1/todos")
          .WithArguments(new { pageNo = pageNo, pageSize = pageSize })
          .WithGeneratedCorelationId()
          .UsingBearerToken(bearer.Token)
          .GetAsync<TodoItem[]>();

        return View(items);
    }
    
    private async Task<AccessToken> GetAuthToken()
    {
        var content = new FormUrlEncodedContent(new KeyValuePair<string?, string?>[]
        {
            new("client_id", "oauthClient"),
            new("client_secret", "SuperSecretPassword"),
            new("scope", "api1.read api1.write"),
            new("grant_type", "client_credentials")
        });

        var authToken = await _clientFactory.Get("identity-server").Endpoint("https://localhost:7094/connect/token")
            .PostAsync<AccessToken>(content);

        return authToken;
    }  
}
//...
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 (3)

Showing the top 3 NuGet packages that depend on YAFLHttp:

Package Downloads
YAFLHttp.AspNet

Fluent API for working with HttpClient in AspNet core

YAFLHttp.Resilience

Fluent API for working with HttpClient in AspNet core

YAFLHttp.SoapMessaging

SOAP Messaging support for YAFLHttp (Fluent API for working with HttpClient in AspNet core)

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.7 98 4/11/2024
1.0.6 109 1/31/2024
1.0.5 220 3/15/2023
1.0.4 288 12/7/2022
1.0.3 401 10/19/2022
1.0.2 377 9/27/2022
1.0.1 420 9/23/2022
1.0.0 417 9/22/2022