Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
packages
src
tests/HttpServiceUnitTests
.editorconfig
.gitattributes
.gitignore
Directory.Build.props
LICENSE
README.md
azure-pipelines.yml
http-client.sln
http-client.sln.DotSettings
nuget.config

README.md

HttpClient

Generic implementation REST api client functional

Interfaces

  • IHttpServiceClient - low level abstraction for non generic cases (for example using of MultipartFormDataContent)
  • IRestClient high level abstraction of rest client works directly with models

Component registration

with Microsoft Dependency Injection framework:

additional decencies

  • Microsoft.Extensions.DependencyInjection
  • Microsoft.Extensions.Http
    var services = new ServiceCollection();
    services.AddSingleton<ISerializer, JsonRestSerializer>();
    services.AddHttpClient<IRestClient, RestClient>();

    return services.BuildServiceProvider();

examples

  • GET
    var httpClient = serviceFactory.GetService<IRestClient>();
    var response = await httpClient.GetAsync<Response<User>>(url).ConfigureAwait(false);
  • POST
    var httpClient = serviceFactory.GetService<IRestClient>();
    var result = await srv.PostAsync<Register, RegisterResponse>(url, model).ConfigureAwait(false);
You can’t perform that action at this time.