An easy way to make HTTP requests to JSON endpoints, with IdentityServer4 integration
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:
- Install the nuget package Geko.HttpClientService
- Provide the options to request an access token in the
appsettings.json
- 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:
- Expand the Geko.HttpClientService.CompleteSample with more functionality.
- Support
JsonSerializerSettings
forJsonConvert.DeserializeObject<TResponseBody>(apiResponse.BodyAsString)
in HttpClientService. - Support more than
ClientCredentialsOptions
andPasswordOptions
. - Set options for changing the x-header name
- 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!