Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use IHttpClientFactory #41

Open
Misiu opened this issue May 20, 2024 · 6 comments
Open

Use IHttpClientFactory #41

Misiu opened this issue May 20, 2024 · 6 comments

Comments

@Misiu
Copy link

Misiu commented May 20, 2024

I plan to use SMSAPI inside a rest API.
The preferred way of using HttpClient is by using https://learn.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-8.0.

Maybe a sample of how to register the client (of the factory) inside DI should be added?

Any info on when the next version of the library will be released?

@mpawikowski
Copy link
Collaborator

Hello,

I forwarded your questions to our IT department.

@jakublabno
Copy link
Collaborator

Hello,
in version 3 we got rid of RestSharp in favour of HttpClient https://github.com/smsapi/smsapi-csharp-client/tree/3.x.x-dev
HttpClient is being created on the fly in ProxyHTTP, so there is no need to be managed by asp core.

Unfortunatelly, there is no common interface for http actions in .net, so what you can do is to make your own implementation of SMSApi.Api.Proxy or decorate it and use it as following

var client = new ClientOAuth("token");
var proxy = YourProxyInstance, you get get it e.g. from your container
var features = new Features(client, proxy);

However, we will discuss about possibillity of passing own HttpClient to proxy.

We are planning to to release 3.x version in a few months, however, if you want, you can build it for you own or contact us to do it so, but pleaes note that it is not fully tested version yet.

The recommended way in asp.net is to keep registered SMSApi.Api.Features service as transient in your service collection

@Misiu
Copy link
Author

Misiu commented May 21, 2024

@jakublabno, thank you for the reply and provided feedback.
Passing HttpClient might help or maybe a custom factory that we could use to return/create httpclient when needed.
I need to use your library in a background service to send messages that are send from multiple microservices, so not sure if transient is a good scope.
I'll take a look at 3.x.x branch and will try to use it in my project.

Looking forward to the release!

@jakublabno
Copy link
Collaborator

@Misiu for now, I've pushed a change eda66cb
Please let me know if it is sufficient for now, also PRs are welcome if you have some good ideas :)

@anddrzejb
Copy link

Is there any roadmap to release 3.x.x? RestSharp is popping up in OWASP vulnerabilities tool.

@jakublabno
Copy link
Collaborator

We had to postpone the release of the new version; however, work has resumed this week. We may also release a pre-release version earlier than stable one.
We'll be ready to release 3.0.0 after our QA teams done testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants