Allow referencing .http file as multiple commads for a web api service
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
when creating new web-api projects (`dotnet new webapi`) a `.http` file is generated.
leveraging these files and being able to use them as simple aspire commands would useful for local dev.
something like this
```cs
public static class HttpCommandsFromHttpFileExtensions
{
public static IResourceBuilder WithHttpCommandsFromHttpFile(this IResourceBuilder builder)
{
builder.ApplicationBuilder.Services.AddHttpClient();
// logic that reads the *.http file and creates commands for each request
// sample command for demonstration purposes
return builder
.WithCommand("http-GET-/api/hello", "GET /api/hello", async context =>
{
var endpoint = builder.GetEndpoint("http");
var client = context.ServiceProvider.GetRequiredService();
var response = await client.GetAsync(endpoint.Url);
var logger = context.ServiceProvider.GetRequiredService().CreateLogger(context.ResourceName);
logger.LogInformation("Response received with status code: {StatusCode}", response.StatusCode);
return new ExecuteCommandResult
{
Success = response.IsSuccessStatusCode,
};
})
;
}
}
```
### Describe the solution you'd like

maybe having a nested menu to allow for multiple requests 🤔
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.