Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
using
statements inPasswordlessClient
.PasswordlessClient
to avoid repetition.I also want to note that the current wiring of
HttpClient
inPasswordlessClient
is not very good. It mutates the state of the client (i.e. sets theBaseUrl
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.
HttpClient
as is and instead set all the required items onHttpRequestMessage
every time it's created. This can be encapsulated in a helper method.PasswordlessHttpHandler
that will wire the correct headers and resolve proper URLs. It can then take the upstreamHttpClient
or anotherHttpMessageHandler
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 on429
responses).This is an example of what the complex approach may look like: