NClient icon indicating copy to clipboard operation
NClient copied to clipboard

Building a client from a delegate

Open smolchanovsky opened this issue 3 years ago • 0 comments

When I want to write in a functional style, I want to skip creating interfaces and use functions. However, it is now impossible to create a client without an interface.

I propose this implementation:

[GetMethod("api/entities/{id}")]
delegate Task<Entity> GetEntityAsync([RouteParam] int id);
...
var getEntityAsync = NClientGallery.Clients.GetRest()
    .For<GetEntityAsync>("https://localhost:5000")
    .Build();

smolchanovsky avatar Dec 16 '21 20:12 smolchanovsky