Skip to content

Ensure WithHttpCommand adds HttpClientFactory#8275

Merged
DamianEdwards merged 1 commit intomainfrom
damianedwards/httpcommand-registerhttpclientfactory
Mar 24, 2025
Merged

Ensure WithHttpCommand adds HttpClientFactory#8275
DamianEdwards merged 1 commit intomainfrom
damianedwards/httpcommand-registerhttpclientfactory

Conversation

@DamianEdwards
Copy link
Copy Markdown
Member

Description

Ensures that IHttpClientFactory is registered in the DistributedApplication DI container when WithHttpCommand is called.

Fixes #8270

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
  • Did you add public API?
    • No
  • Does the change make any security assumptions or guarantees?
    • No
  • Does the change require an update in our Aspire docs?
    • No

Copilot AI review requested due to automatic review settings March 24, 2025 19:45
@github-actions github-actions bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Mar 24, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that IHttpClientFactory is registered in the DI container when WithHttpCommand is invoked, enabling HTTP commands to function as expected. Key changes include:

  • Adding a call to register IHttpClientFactory via AddHttpClient() in the WithHttpCommand extension.
  • Introducing a new unit test to verify that the IHttpClientFactory is added to the service collection.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Aspire.Hosting/ResourceBuilderExtensions.cs Registers IHttpClientFactory in the DI container within WithHttpCommand
tests/Aspire.Hosting.Tests/WithHttpCommandTests.cs Adds unit tests to validate the HTTP client factory registration

@DamianEdwards DamianEdwards requested a review from davidfowl March 24, 2025 19:45
@DamianEdwards DamianEdwards merged commit ccf05c8 into main Mar 24, 2025
164 checks passed
@DamianEdwards DamianEdwards deleted the damianedwards/httpcommand-registerhttpclientfactory branch March 24, 2025 20:27
@github-actions github-actions bot locked and limited conversation to collaborators Apr 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The WithHttpCommand API makes an assumption

4 participants