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

[Proposal] Add new constructor to Jikan class #23

Closed
N0D4N opened this issue Nov 27, 2020 · 2 comments
Closed

[Proposal] Add new constructor to Jikan class #23

N0D4N opened this issue Nov 27, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@N0D4N
Copy link
Contributor

N0D4N commented Nov 27, 2020

Add new constructor to Jikan class which accepts custom, user-provided HttpClient.

Reasoning

With this feature user will be able to provide custom HttpClient with preconfigured HttpMessageHandler, make HttpClient resilient with Polly for example etc.

Currently it is possible to achieve the same thing via reflection or with implementing IJikan interface and making such constructor, however both ways are looking tricky to me.

Proposed API

/// <summary>
/// Constructor.
/// </summary>
/// <param name="httpClient">Http client to call REST request and receive REST response</param>
/// <param name="suppressException">Should exception be thrown in case of failed request. If true, failed request return null.</param>
public Jikan(HttpClient httpClient, bool suppressException = false)
{
_suppressException = suppressException;
_httpClient = httpClient
}

Optionally check httpClient instance for being null.

I can make a PR for this.

@Ervie
Copy link
Owner

Ervie commented Nov 27, 2020

Sounds reasonable, I'll add it. One disadvantage of that would be that user has to take care to prepare endpoint for HttpClient themselves - I think it should be documented.

Also when Jikan v4 will hit, next version will be probably tagged as 2.0 and have constructor reworked to avoid creating infinite combinations - probably one parameterless and second with object (maybe named JikanOptions or something similar).

@Ervie
Copy link
Owner

Ervie commented Nov 27, 2020

Done, version 1.5.3 should be visible shortly.

@Ervie Ervie added the enhancement New feature or request label Nov 27, 2020
@Ervie Ervie closed this as completed Nov 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants