NClient
NClient copied to clipboard
Building a client from a delegate
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();