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

Fix warnings #39

Merged
merged 4 commits into from
Sep 26, 2023
Merged

Fix warnings #39

merged 4 commits into from
Sep 26, 2023

Conversation

Tyrrrz
Copy link
Contributor

@Tyrrrz Tyrrrz commented Sep 25, 2023

  • Fixed the warnings related to docs and some other minor issues.
  • Added missing using statements in PasswordlessClient.
  • Tried to optimize constructor calls in PasswordlessClient to avoid repetition.

I also want to note that the current wiring of HttpClient in PasswordlessClient is not very good. It mutates the state of the client (i.e. sets the BaseUrl property and adds default headers). This is suboptimal because clients can be reused and changing those properties may cause issues in other parts of the program.

There are two recommended approaches.

  1. (Basic) Take the HttpClient as is and instead set all the required items on HttpRequestMessage every time it's created. This can be encapsulated in a helper method.
  2. (Complex) Create a PasswordlessHttpHandler that will wire the correct headers and resolve proper URLs. It can then take the upstream HttpClient or another HttpMessageHandler in its delegation chain. This is too complex for this situation but might be reasonable if we want to add things like custom retry handling (for example on 429 responses).

This is an example of what the complex approach may look like:

@Tyrrrz
Copy link
Contributor Author

Tyrrrz commented Sep 25, 2023

@abergs @justindbaur I reverted the constructor changes because they warrant their own, larger PR. Please review the remaining changes so I can merge.

@Tyrrrz Tyrrrz changed the title Fix warnings and optimize constructor calls Fix warnings Sep 25, 2023
Copy link
Member

@abergs abergs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

src/Passwordless/PasswordlessClient.cs Show resolved Hide resolved
src/Passwordless/PasswordlessClient.cs Show resolved Hide resolved
@Tyrrrz Tyrrrz merged commit d1c5b0c into main Sep 26, 2023
4 checks passed
@Tyrrrz Tyrrrz deleted the fix-warns branch September 26, 2023 13:49
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

Successfully merging this pull request may close these issues.

2 participants