Skip to content

Transport

Stanislav Molchanovskiy edited this page Nov 15, 2021 · 1 revision

To deliver the request to the endpoint, you need transport. By default, HTTP transport (NClient.Providers.Transport.Http.System package) is used for message delivery in pre-configurated clients. To use it for your custom client, you should call the UsingHttpTransport method:

IMyClient myClient = NClientGallery.Clients.GetCustom()
    .For<IMyClient>(host: "http://localhost:8080")
    .UsingRestApi()
    .UsingHttpTransport()
    ...
    .Build();

If you are not satisfied with HTTP transport, you can implement your own and use it in the client. To do this, you will need to create your custom implementation of transport and pass it to the UsingCustomTransport method:

ITransportProvider<TRequest, TResponse> myTransportProvider = ...;
ITransportRequestBuilderProvider<TRequest, TResponse> myTransportRequestBuilderProvider = ...;
IResponseBuilderProvider<TRequest, TResponse> myResponseBuilderProvider = ...;

IMyClient myClient = NClientGallery.Clients.GetCustom()
    .For<IMyClient>(host: "http://localhost:8080")
    .UsingRestApi()
    .UsingCustomTransport(
        myTransportProvider, 
        myTransportRequestBuilderProvider, 
        myResponseBuilderProvider)
    ...
    .Build();
Clone this wiki locally