-
Notifications
You must be signed in to change notification settings - Fork 11
Providers
Providers give additional implementations for sending HTTP requests, serialization, and resilience. You can use the providers listed below or implement your own.
The package NClient.Providers.Api.Rest implements the conversion of an interface method call into a REST request. This package is included in the NClient package dependencies and is the default provider for REST clients. To use this provider, you need to call the UsingRestApi
method when building a client.
The package NClient.Providers.Transport.SystemNetHttp implements transport to the endpoint for requests over HTTP using System.Net.Http
. This package is included in the NClient package dependencies and is the default provider for the HTTP transport implementation. To use this provider, you need to call the UsingSystemNetHttpTransport
method (or its alias UsingHttpTransport
) when building a client.
The package NClient.Providers.Transport.RestSharp implements transport to the endpoint for requests over HTTP using the RestSharp library. This can be useful, for example, to switch from the RestSharp library to NClient - you can return standard RestSharp (IRestResponse) responses from client interface methods.
To use RestSharp
client instead of the default one, you need to install package and use the UsingRestSharpTransport
method:
IMyClient myClient = NClientGallery.Clients.GetRest()
.For<IMyClient>(host: "http://localhost:8080")
.UsingRestSharpTransport()
.Build();
Keep in mind that RestSharp uses legacy HttpWebRequest
, so it won't work in Blazor.
The package NClient.Providers.Serialization.SystemTextJson implements JSON serialization using System.Text.Json
. This package is included in the NClient package dependencies and is the default provider for the serialization implementation. To use this provider, you need to call the UsingSystemTextJsonSerialization
method (or its alias UsingJsonSerializer
) when building a client.
The package NClient.Providers.Serialization.NewtonsoftJson implements JSON serialization using Newtonsoft.Json. This package will be useful if you need deserialization of generics or some Newtonsoft functionality. If you want to use Newtonsoft.Json for serialization, you need to install package and use the UsingNewtonsoftJsonSerialization
method:
IMyClient myClient = NClientGallery.Clients.GetRest()
.For<IMyClient>(host)
.UsingNewtonsoftJsonSerialization()
.Build();
The package NClient.Providers.Serialization.SystemXml implements XML serialization using System.Xml.Serialization
. If you want to use System.Xml.Serialization
for serialization, you need to install package and use the WithSystemXmlSerialization
method:
IMyClient myClient = NClientGallery.Clients.GetRest()
.For<IMyClient>(host)
.WithSystemXmlSerialization()
.Build();
The package NClient.Providers.Serialization.MessagePack implements MessagePack serialization using MessagePackCSharp. If you want to use MessagePack for serialization, you need to install package and use the WithMessagePackSerialization
method:
IMyClient myClient = NClientGallery.Clients.GetRest()
.For<IMyClient>(host)
.WithMessagePackSerialization()
.Build();
The package NClient.Providers.Serialization.ProtobufNet implements ProtobufNet serialization using ProtobufNet. If you want to use ProtobufNet for serialization, you need to install package and use the WithProtobufNetSerialization
method:
IMyClient myClient = NClientGallery.Clients.GetRest()
.For<IMyClient>(host)
.WithProtobufNetSerialization()
.Build();
The package NClient.Providers.Resilience.Polly implements resilience for client method calls. This package is included in the NClient package dependencies and is the default provider for resilience. To use this provider, you need to call the WithPolly*
method and other with the prefix Polly
.
The package NClient.Providers.Mapping.HttpResponses implements mapping to a set of models representing HTTP responses with deserialized data that can be used as return types of client methods. This package is included in the NClient and the mapper from the package is already in the client. To use this provider for custom clients, you need to call the WithResponseToHttpResponseMapping
method when building a client.
The package NClient.Providers.Mapping.LanguageExt implements mapping to a set of monads from LanguageExt library that can be used as return types of client methods. To use this provider, you need to call the WithResponseToMonadMapping
method when building a client.