# ResourceWithEndpoints.WithEndpoint

- Module: [Aspire.Hosting](/reference/api/go/aspire.hosting.md)
- Defined on: [ResourceWithEndpoints](/reference/api/go/aspire.hosting/resourcewithendpoints.md)
- Version: `17.0.0`
- Kind: `method`

Adds a network endpoint

## Definition

```go
func (ResourceWithEndpoints) WithEndpoint(options ...*WithEndpointOptions) ResourceWithEndpoints
```

## Signature

```go
WithEndpoint(options ...*WithEndpointOptions) ResourceWithEndpoints
```

## Parameters

- `options` (`...*WithEndpointOptions`) -- optional settings, see [Options](#options)

## Options

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

- `Port` (`*float64`) -- An optional port. This is the port that will be given to other resource to communicate with this resource.
- `TargetPort` (`*float64`) -- This is the port the resource is listening on. If the endpoint is used for the container, it is the container port.
- `Scheme` (`*string`) -- An optional scheme e.g. (http/https). Defaults to the `protocol` argument if it is defined or "tcp" otherwise.
- `Name` (`*string`) -- An optional name of the endpoint. Defaults to the scheme name if not specified.
- `Env` (`*string`) -- An 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` (`*bool`) -- Specifies if the endpoint will be proxied by DCP. Defaults to `null`.
- `IsExternal` (`*bool`) -- Indicates that this endpoint should be exposed externally at publish time.
- `Protocol` (`*ProtocolType`) -- Network protocol: TCP or UDP are supported today, others possibly in future.

## Returns

[`ResourceWithEndpoints`](/reference/api/go/aspire.hosting/resourcewithendpoints.md) -- The resource builder.

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

## Defined on

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

- [ResourceWithEndpoints](/reference/api/go/aspire.hosting/resourcewithendpoints.md) -- `marker`

## Applies to

- [`CSharpAppResource`](/reference/api/go/aspire.hosting/csharpappresource.md)
- [`ContainerResource`](/reference/api/go/aspire.hosting/containerresource.md)
- [`DotnetToolResource`](/reference/api/go/aspire.hosting/dotnettoolresource.md)
- [`ExecutableResource`](/reference/api/go/aspire.hosting/executableresource.md)
- [`ProjectResource`](/reference/api/go/aspire.hosting/projectresource.md)
