Add an extension method to add Dapr HTTP Client to service collection
See original GitHub issueDescribe the proposal
Currently, we can call the CreateInvokeHttpClient from DaprClient to create a preconfigured HttpClient. It would be great to leverage the IHttpClientFactory of ASP.NET Core with the same level of integration as the CreateInvokeHttpClient.
In short, there’s how it could be used :
services.AddDaprHttpClient<CartClient, CartClient>("appId");
I’ve created a PR to see how it could be implemented.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
How-To: Invoke services using HTTP | Dapr Docs
To invoke an application using Dapr, you can use the invoke API on any Dapr instance. The sidecar programming model encourages each application...
Read more >DaprServiceCollectionExtensions.cs
Search code, repositories, users, issues, pull requests... · Provide feedback · Saved searches · DaprServiceCollectionExtensions.cs ...
Read more >Getting started with the Dapr client .NET SDK
How to get up and running with the Dapr .NET SDK. ... Http.HttpClient to invoke your services. SDK; HTTP. using var client =...
Read more >DaprClient usage
A DaprClient can be configured by invoking methods on DaprClientBuilder class before calling .Build() to create the client. The settings for each DaprClient...
Read more >Building Microservices by Using Dapr and .NET with ...
Run("http://localhost:5000");. Here, we have included Dapr in the service collection by using the AddDaprClient extension method.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@rynowak Actually I got it to work based upon your example…
Very simple so thank you!
Hi @rynowak, I have to agree with you. I realized yesterday while implementing the basic method that it will imply to have a lot of code to support all overloads.
For me, the need was mainly a concern of adopting the best-practices for ASP.NET about the IHttpClientFactory. It will be useful to have the possibility to add global policies like retries, but it seems that Dapr will solve this early soon. So I think it’s not a good idea to add code in the SDK that have high chance to be useless in the short term.
IMHO, the second sample you provide is nice. I personaly don’t like to have http:// strings in the code.
For sure, adding this to documentation would be a great addition.