-
Notifications
You must be signed in to change notification settings - Fork 703
Description
Just tried out the new WithUrls option added in 9.2. Use case is I want to add a swagger url to my resource. We currently have a custom resource command to do this, but with the WithCommand we used being deprecated, seemed like moving to a native url was the best option.
First attempt was to try something like:
var endpoint = builder.Resource.GetEndpoint(endpointName);
builder.WithUrl($"{endpoint}/swagger", "swagger");But this doesn't compile as the url has to be a string.
I found WithUrlForEndpoint which sort of works for what I want, however it replaces over the existing url, whereas I wanted the swagger link to be an additional link
builder.WithUrlForEndpoint(endpointName, x =>
{
x.Url += "/swagger";
x.DisplayText = "Swagger UI";
});There is WithUrls which creates an additional url, but now it has some strange UX whereby the Swagger url shows as soon as aspire starts up, but the http://loclhoast:1234 doesn't show up until the resource has finished waiting and actually starts
builder.WithUrls(ctx => ctx.Urls.Add(new ResourceUrlAnnotation
{
Url = $"{endpoint.Url}/swagger",
DisplayText = "Swagger UI",
}));- Should there be an overload of
WithUrl()that allowsurlto be aReferenceExpression? - Is there a way to delay showing the url until the resource is actually started? (and should this be the default behavior)