Skip to content

Api protocols

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

Currently, only the REST API protocol is provided as a ready-made implementation. To use it, you just need to create a client via NClientGallery.Clients.GetRest method. To use it in your custom client configuration, you need to call the UsingRestApi method:

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

If you need a non-REST protocol, you have the opportunity to create your own implementation of converting an interface method call into a request. To do this, you will need to implement the IRequestBuilderProvider interface and pass its implementation to the UsingCustomApi method:

IRequestBuilderProvider myRequestBuilderProvider = ...;

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