nclient / NClient

:dizzy: NClient is an automatic type-safe .Net HTTP client that allows you to call web service API methods using annotated interfaces or controllers without boilerplate code.
Apache License 2.0
43 stars 11 forks source link

Building a client from a delegate #382

Open smolchanovsky opened 2 years ago

smolchanovsky commented 2 years ago

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();