An easy way to make HTTP requests to JSON endpoints, with IdentityServer4 integration

Build Status Nuget

An almost 2x times faster fluent HTTP request service, build to simplify the communication with JSON endpoints, by automatically handling serialization / deserialization. Authenticated requests towards protected by IdentityServer4 resources are done in a simple compact way.

Add it to the service collection in Startup.cs

  services.AddHttpClientService();
  
  //Or if the resources are behind an IdentityServer4
  services.AddHttpClientService(
          .Configure<ClientCredentialsOptions>(Configuration.GetSection(nameof(ClientCredentialsOptions)));

Calls can be easy as that :)

var responseObject = await _requestServiceFactory
 //Create a instance of the service
 .CreateHttpClientService()
 //GET and deserialize the response body to IEnumerable<Customers>
 .GetAsync<IEnumerable<Customers>>("https://api/customers");

Getting Started

Getting started with Geko.HttpClientService is easy; you only need three things:

  1. Install the nuget package Geko.HttpClientService
  2. Provide the options to request an access token in the appsettings.json
  3. Register the service in Startup.cs

Read the entire Getting Started guide for a quick start. You can also take a look at the Documentation, check the features sample or a more complete one.

More Details

Read the 'More Details' section for a more detailed explanation on some of the features of this library, like the SetIdentityServerOptions overloads, the ResponseObject and the TypeContent(TRequestBody, Encoding, string) class

Contributing

Feedback and contibution is more than welcome, as there are many more things to do!

Just as a sample:

  1. Expand the Geko.HttpClientService.CompleteSample with more functionality.
  2. Support JsonSerializerSettings for JsonConvert.DeserializeObject<TResponseBody>(apiResponse.BodyAsString) in HttpClientService.
  3. Support more than ClientCredentialsOptions and PasswordOptions.
  4. Set options for changing the x-header name
  5. Add logging.

Many more are coming soon and all of them should be issues, so feel free to open one and let's start discussing solutions!

  • Improve this Doc
Back to top Generated by DocFX