-
Notifications
You must be signed in to change notification settings - Fork 773
Add WithHttpCommand #7962
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
Add WithHttpCommand #7962
Conversation
There was a problem hiding this 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),
eerhardt
left a comment
There was a problem hiding this 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.
mitchdenny
left a comment
There was a problem hiding this 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.
Description
Adds
WithHttpCommand()to allow easily adding a resource command that sends an HTTP request to an endpoint.Fixes #6649
Checklist
<remarks />and<code />elements on your triple slash comments?