Skip to content

Allow WithUrl to reference an endpoint without breaking the fluent chain #8638

@afscrome

Description

@afscrome

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

Right now if you want to add a custom url referencing an endpoint, you have to break the fluent chain

var resource = builder.AddContainer("redis", "redis")
    .WithHttpEndpoint(targetPort: 8080);

resource.WithUrl($"{resource.GetEndpoint("http")}/swagger", "Swagger");

Describe the solution you'd like

For this specific case, it would be really nice if you could handle this without having to break the chain

   builder.AddContainer("redis", "redis")
         .WithHttpEndpoint(targetPort: 8080)
         .WithUrl("http", "/swagger", "Swagger");

(This suggestion suggestion would likely require #8636 to work)

That said, there is a more general problem here that a number of APIs have (e.g. try to add a url to an environment variable). So you could argue for a more general solution, rather than adding more WithUrl overloads. But given that urls are closely linked with endpoints, I don't see too many problems having special handling for endpoints in WithUrl here.

Additional context

The only gotcha I'd think about in scope for 9.2 is that if we did want to implement the api suggested above, there will be a conflict between:

// Existing method
WithUrl(string url, string ? displayText = null)
// New method
WithUrl(string endpoint, string url, string ? displayText = null)

Which would need a breaking change to resolve. So it could be worth doing something now that avoids a breaking change later.

(To be clear, I'm not strongly pushing for this to be done in 9.2, I just think it's worth thinking about)

cc @DamianEdwards

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions