Skip to content

Conversation

@DamianEdwards
Copy link
Member

Description

Adds WithHttpCommand() to allow easily adding a resource command that sends an HTTP request to an endpoint.

Fixes #6649

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Ye
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
  • Does the change make any security assumptions or guarantees?
    • No
  • Does the change require an update in our Aspire docs?

Copilot AI review requested due to automatic review settings March 8, 2025 01:46
Copy link
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.

PR Overview

This pull request adds the WithHttpCommand() feature to simplify sending HTTP requests as resource commands. Key changes include:

  • Introducing WithHttpCommand overloads with customizable endpoint selection and request configuration.
  • Adding comprehensive tests for the HTTP command functionality.
  • Updating existing infrastructure (such as endpoint mapping and command result handling) to support the new feature.

Reviewed Changes

File Description
playground/TestShop/CatalogDb/ResetDbExtensions.cs Adds an endpoint to reset the catalog database in development.
tests/Aspire.Hosting.Tests/WithHttpCommandTests.cs Provides unit tests covering various WithHttpCommand scenarios.
playground/TestShop/CatalogDb/Program.cs Integrates the reset DB endpoint into the web application when in development.
playground/TestShop/TestShop.AppHost/Program.cs Configures a reset-db command with environment variables and custom HTTP request configuration.
src/Aspire.Hosting/ApplicationModel/ResourceCommandAnnotation.cs Updates command result methods for a more concise implementation.
tests/testproject/TestProject.ServiceA/Program.cs Adds endpoints needed to support HTTP command tests in the test project.
src/Aspire.Hosting/ResourceBuilderExtensions.cs Adds new WithHttpCommand overloads and a PreferredEndpointSelector overload for endpoint name selection.
src/Shared/StringComparers.cs Introduces a comparer for endpoint URI schemes.
playground/TestShop/CatalogDb/CatalogDbInitializer.cs Adjusts database initialization logic and method accessibility for improved diagnostics.

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

Comments suppressed due to low confidence (1)

src/Aspire.Hosting/ResourceBuilderExtensions.cs:1221

  • The syntax '[endpointName]' is invalid; please replace it with a proper string array such as 'new string[] { endpointName }' to correctly select the endpoint by name.
endpointSelector: endpointName is not null ? PreferredEndpointSelector(builder, [endpointName]) : PreferredEndpointSelector(builder, s_httpSchemes),

@DamianEdwards DamianEdwards requested a review from JamesNK March 8, 2025 21:53
@github-actions github-actions bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Mar 10, 2025
Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me. I just had some questions/comments.

Copy link
Member

@mitchdenny mitchdenny left a comment

Choose a reason for hiding this comment

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

This looks good to me. One piece of feedback about exposing the command execution context on the request configuration callback. It is a very long over-load but I think everything there is stuff that we'll be asked for if we don't add it.

@DamianEdwards DamianEdwards merged commit 07b7c74 into main Mar 11, 2025
137 checks passed
@DamianEdwards DamianEdwards deleted the damianedwards/httpcommand branch March 11, 2025 16:47
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 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.

WithHttpsCommand extension

6 participants