Aspirerelease/17.0
Watch Aspire live streamsDocsTry Aspire

ResourceWithEndpoints

Interfacemarker
📦 Aspire.Hosting v17.0.0

Represents a resource that has endpoints associated with it.

type ResourceWithEndpoints interface{}

Methods

A marker interface declares no methods of its own in Go. Its functions are declared on the concrete types they apply to.

methodAsHttp2Servicebuilder
Configures a resource to mark all endpoints' transport as HTTP/2. This is useful for HTTP/2 services that need prior knowledge.
AsHttp2Service() ResourceWithEndpoints
ResourceWithEndpoints

The resource builder.

Returns a handle; failures surface later via Err().

Gets an endpoint reference
GetEndpoint(name string) EndpointReference
namestringThe name of the endpoint.
EndpointReference

An EndpointReference that can be used to resolve the address of the endpoint after resource allocation has occurred.

Returns a handle; failures surface later via Err().

Subscribes to the ResourceEndpointsAllocated event.
OnResourceEndpointsAllocated(callback func(arg ResourceEndpointsAllocatedEvent)) ResourceWithEndpoints
callbackfunc(arg ResourceEndpointsAllocatedEvent)callbackThe callback to invoke when the event fires.
ResourceWithEndpoints

The resource builder.

Returns a handle; failures surface later via Err().

methodWithEndpointbuilder
Adds a network endpoint
WithEndpoint(options ...*WithEndpointOptions) ResourceWithEndpoints
options...*WithEndpointOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithEndpointOptions argument.

Port*float64An optional port. This is the port that will be given to other resource to communicate with this resource.
TargetPort*float64This is the port the resource is listening on. If the endpoint is used for the container, it is the container port.
Scheme*stringAn optional scheme e.g. (http/https). Defaults to the protocol argument if it is defined or "tcp" otherwise.
Name*stringAn optional name of the endpoint. Defaults to the scheme name if not specified.
Env*stringAn optional name of the environment variable that will be used to inject the targetPort. If the target port is null one will be dynamically generated and assigned to the environment variable.
IsProxied*boolSpecifies if the endpoint will be proxied by DCP. Defaults to null.
IsExternal*boolIndicates that this endpoint should be exposed externally at publish time.
Protocol*ProtocolTypeNetwork protocol: TCP or UDP are supported today, others possibly in future.
ResourceWithEndpoints

The resource builder.

Returns a handle; failures surface later via Err().

Updates a named endpoint via callback
WithEndpointCallback(
endpointName string,
callback func(obj EndpointUpdateContext),
options ...*WithEndpointCallbackOptions,
) ResourceWithEndpoints
endpointNamestring
callbackfunc(obj EndpointUpdateContext)callback
options...*WithEndpointCallbackOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithEndpointCallbackOptions argument.

CreateIfNotExists*bool
ResourceWithEndpoints

Returns a handle; failures surface later via Err().

Set whether a resource can use proxied endpoints or whether they should be disabled for all endpoints belonging to the resource. If set to false, endpoints belonging to the resource will ignore the configured proxy settings and run proxy-less.
WithEndpointProxySupport(proxyEnabled bool) ResourceWithEndpoints
proxyEnabledboolShould endpoints for the resource support using a proxy?
ResourceWithEndpoints

The resource builder.

Returns a handle; failures surface later via Err().

Marks existing http or https endpoints on a resource as external.
WithExternalHttpEndpoints() ResourceWithEndpoints
ResourceWithEndpoints

The resource builder.

Returns a handle; failures surface later via Err().

methodWithHttpCommandbuilder
Adds an HTTP resource command
WithHttpCommand(
path string,
displayName string,
options ...*HttpCommandExportOptions,
) ResourceWithEndpoints
pathstring
displayNamestring
options...*HttpCommandExportOptionsOptional settings, described under Options.

Optional parameters are passed as the existing *HttpCommandExportOptions struct.

ResourceWithEndpoints

Returns a handle; failures surface later via Err().

methodWithHttpEndpointbuilder
Adds an HTTP endpoint
WithHttpEndpoint(options ...*WithHttpEndpointOptions) ResourceWithEndpoints
options...*WithHttpEndpointOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithHttpEndpointOptions argument.

Port*float64An optional port. This is the port that will be given to other resource to communicate with this resource.
TargetPort*float64This is the port the resource is listening on. If the endpoint is used for the container, it is the container port.
Name*stringAn optional name of the endpoint. Defaults to "http" if not specified.
Env*stringAn optional name of the environment variable to inject.
IsProxied*boolSpecifies if the endpoint will be proxied by DCP. Defaults to null.
ResourceWithEndpoints

The resource builder.

Returns a handle; failures surface later via Err().

Updates an HTTP endpoint via callback
WithHttpEndpointCallback(
callback func(obj EndpointUpdateContext),
options ...*WithHttpEndpointCallbackOptions,
) ResourceWithEndpoints
callbackfunc(obj EndpointUpdateContext)callback
options...*WithHttpEndpointCallbackOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithHttpEndpointCallbackOptions argument.

Name*string
CreateIfNotExists*bool
ResourceWithEndpoints

Returns a handle; failures surface later via Err().

methodWithHttpHealthCheckbuilder
Adds a health check to the resource which is mapped to a specific endpoint.
WithHttpHealthCheck(options ...*WithHttpHealthCheckOptions) ResourceWithEndpoints
options...*WithHttpHealthCheckOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithHttpHealthCheckOptions argument.

Path*stringThe relative path to test.
StatusCode*float64The result code to interpret as healthy.
EndpointName*stringThe name of the endpoint to derive the base address from.
ResourceWithEndpoints

The resource builder.

Returns a handle; failures surface later via Err().

methodWithHttpProbebuilder
Adds an HTTP health probe to the resource
WithHttpProbe(
probeType ProbeType,
options ...*WithHttpProbeOptions,
) ResourceWithEndpoints
probeTypeProbeType
options...*WithHttpProbeOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithHttpProbeOptions argument.

Path*string
InitialDelaySeconds*float64
PeriodSeconds*float64
TimeoutSeconds*float64
FailureThreshold*float64
SuccessThreshold*float64
EndpointName*string
ResourceWithEndpoints

Returns a handle; failures surface later via Err().

methodWithHttpsEndpointbuilder
Adds an HTTPS endpoint
WithHttpsEndpoint(options ...*WithHttpsEndpointOptions) ResourceWithEndpoints
options...*WithHttpsEndpointOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithHttpsEndpointOptions argument.

Port*float64An optional host port.
TargetPort*float64This is the port the resource is listening on. If the endpoint is used for the container, it is the container port.
Name*stringAn optional name of the endpoint. Defaults to "https" if not specified.
Env*stringAn optional name of the environment variable to inject.
IsProxied*boolSpecifies if the endpoint will be proxied by DCP. Defaults to null.
ResourceWithEndpoints

The resource builder.

Returns a handle; failures surface later via Err().

Updates an HTTPS endpoint via callback
WithHttpsEndpointCallback(
callback func(obj EndpointUpdateContext),
options ...*WithHttpsEndpointCallbackOptions,
) ResourceWithEndpoints
callbackfunc(obj EndpointUpdateContext)callback
options...*WithHttpsEndpointCallbackOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithHttpsEndpointCallbackOptions argument.

Name*string
CreateIfNotExists*bool
ResourceWithEndpoints

Returns a handle; failures surface later via Err().

methodWithMcpServerbuilder
Marks the resource as hosting a Model Context Protocol (MCP) server on the specified endpoint.
WithMcpServer(options ...*WithMcpServerOptions) ResourceWithEndpoints
options...*WithMcpServerOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithMcpServerOptions argument.

Path*stringAn optional path to append to the endpoint URL when forming the MCP server address. Defaults to "/mcp".
EndpointName*stringAn optional name of the endpoint that hosts the MCP server. If not specified, defaults to the first HTTPS or HTTP endpoint.
ResourceWithEndpoints

The resource builder.

Returns a handle; failures surface later via Err().

Applies to

This interface applies to the following types: