Foundry-Local
Foundry-Local copied to clipboard
Make `HttpClient` injectable for C# SDK
The HttpClient used by the C# SDK is created in the StartServiceAsync, which means that you have no ability to interact with it - this can be seen in the unit tests having to rely on reflection to provide a mock implementation.
This also becomes a problem if you want to adjust the timeout, add some resilience layer, or anything of that nature.
Making the HttpClient something provided by the constructor, or alternatively a HttpClientFactory, allows for more flexibility in working with the SDK.
Doing this would allow for some better logging and telemetry with the Aspire integration.