Поделиться через


ResourceBuilderExtensions.WithUrlForEndpoint<T> Method

Definition

Registers a callback to update the URL displayed for the endpoint with the specified name.

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<T> WithUrlForEndpoint<T>(this Aspire.Hosting.ApplicationModel.IResourceBuilder<T> builder, string endpointName, Action<Aspire.Hosting.ApplicationModel.ResourceUrlAnnotation> callback) where T : Aspire.Hosting.ApplicationModel.IResource;
static member WithUrlForEndpoint : Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.IResource)> * string * Action<Aspire.Hosting.ApplicationModel.ResourceUrlAnnotation> -> Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.IResource)> (requires 'T :> Aspire.Hosting.ApplicationModel.IResource)
<Extension()>
Public Function WithUrlForEndpoint(Of T As IResource) (builder As IResourceBuilder(Of T), endpointName As String, callback As Action(Of ResourceUrlAnnotation)) As IResourceBuilder(Of T)

Type Parameters

T

The resource type.

Parameters

builder
IResourceBuilder<T>

The builder for the resource.

endpointName
String

The name of the endpoint to customize the URL for.

callback
Action<ResourceUrlAnnotation>

The callback that will customize the URL.

Returns

The IResourceBuilder<T>.

Examples

Customize the URL for the "https" endpoint to use the link text "Home":

var frontend = builder.AddProject<Projects.Frontend>("frontend")
                      .WithUrlForEndpoint("https", url => url.DisplayText = "Home");

Remarks

Use this method to customize the URL that is automatically added for an endpoint on the resource.

The callback will be executed after endpoints have been allocated and the URL has been generated.
This allows you to modify the URL or its display text.

If the endpoint with the specified name does not exist, the callback will not be executed and a warning will be logged.

Applies to