# IResourceWithEndpoints

- Module: [Aspire.Hosting](/reference/api/typescript/aspire.hosting.md)
- Version: `13.4.0`
- Kind: `interface`
- Source: [GitHub](https://github.com/microsoft/aspire)

Represents a resource that has endpoints associated with it.

## Definition

```typescript
interface IResourceWithEndpoints {
  asHttp2Service(): IResourceWithEndpoints;
  getEndpoint(name: string): EndpointReference;
  onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise<void>): IResourceWithEndpoints;
  withEndpoint(
      port?: number,
      targetPort?: number,
      scheme?: string,
      name?: string,
      env?: string,
      isProxied?: boolean,
      isExternal?: boolean,
      protocol?: ProtocolType): IResourceWithEndpoints;
  withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise<void>, createIfNotExists?: boolean): IResourceWithEndpoints;
  withEndpointProxySupport(proxyEnabled: boolean): IResourceWithEndpoints;
  withExternalHttpEndpoints(): IResourceWithEndpoints;
  withHttpCommand(
      path: string,
      displayName: string,
      options?: HttpCommandExportOptions): IResourceWithEndpoints;
  withHttpEndpoint(
      port?: number,
      targetPort?: number,
      name?: string,
      env?: string,
      isProxied?: boolean): IResourceWithEndpoints;
  withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise<void>, name?: string, createIfNotExists?: boolean): IResourceWithEndpoints;
  withHttpHealthCheck(
      path?: string,
      statusCode?: number,
      endpointName?: string): IResourceWithEndpoints;
  withHttpProbe(
      probeType: ProbeType,
      path?: string,
      initialDelaySeconds?: number,
      periodSeconds?: number,
      timeoutSeconds?: number,
      failureThreshold?: number,
      successThreshold?: number,
      endpointName?: string): IResourceWithEndpoints;
  withHttpsEndpoint(
      port?: number,
      targetPort?: number,
      name?: string,
      env?: string,
      isProxied?: boolean): IResourceWithEndpoints;
  withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise<void>, name?: string, createIfNotExists?: boolean): IResourceWithEndpoints;
  withMcpServer(
      path?: string,
      endpointName?: string): IResourceWithEndpoints;
}
```

## Methods

- [asHttp2Service](/reference/api/typescript/aspire.hosting/iresourcewithendpoints/ashttp2service.md) -- `method` -- Configures a resource to mark all endpoints' transport as HTTP/2. This is useful for HTTP/2 services that need prior knowledge.
    ```typescript
  asHttp2Service(): IResourceWithEndpoints
  ```
- [getEndpoint](/reference/api/typescript/aspire.hosting/iresourcewithendpoints/getendpoint.md) -- `method` -- Gets an endpoint reference
    ```typescript
  getEndpoint(name: string): EndpointReference
  ```
- [onResourceEndpointsAllocated](/reference/api/typescript/aspire.hosting/iresourcewithendpoints/onresourceendpointsallocated.md) -- `method` -- Subscribes to the ResourceEndpointsAllocated event.
    ```typescript
  onResourceEndpointsAllocated(callback: (arg: ResourceEndpointsAllocatedEvent) => Promise<void>): IResourceWithEndpoints
  ```
- [withEndpoint](/reference/api/typescript/aspire.hosting/iresourcewithendpoints/withendpoint.md) -- `method` -- Adds a network endpoint
    ```typescript
  withEndpoint(port?: number, targetPort?: number, scheme?: string, name?: string, env?: string, isProxied?: boolean, isExternal?: boolean, protocol?: ProtocolType): IResourceWithEndpoints
  ```
- [withEndpointCallback](/reference/api/typescript/aspire.hosting/iresourcewithendpoints/withendpointcallback.md) -- `method` -- Updates a named endpoint via callback
    ```typescript
  withEndpointCallback(endpointName: string, callback: (obj: EndpointUpdateContext) => Promise<void>, createIfNotExists?: boolean): IResourceWithEndpoints
  ```
- [withEndpointProxySupport](/reference/api/typescript/aspire.hosting/iresourcewithendpoints/withendpointproxysupport.md) -- `method` -- 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.
    ```typescript
  withEndpointProxySupport(proxyEnabled: boolean): IResourceWithEndpoints
  ```
- [withExternalHttpEndpoints](/reference/api/typescript/aspire.hosting/iresourcewithendpoints/withexternalhttpendpoints.md) -- `method` -- Marks existing http or https endpoints on a resource as external.
    ```typescript
  withExternalHttpEndpoints(): IResourceWithEndpoints
  ```
- [withHttpCommand](/reference/api/typescript/aspire.hosting/iresourcewithendpoints/withhttpcommand.md) -- `method` -- Adds an HTTP resource command
    ```typescript
  withHttpCommand(path: string, displayName: string, options?: HttpCommandExportOptions): IResourceWithEndpoints
  ```
- [withHttpEndpoint](/reference/api/typescript/aspire.hosting/iresourcewithendpoints/withhttpendpoint.md) -- `method` -- Adds an HTTP endpoint
    ```typescript
  withHttpEndpoint(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): IResourceWithEndpoints
  ```
- [withHttpEndpointCallback](/reference/api/typescript/aspire.hosting/iresourcewithendpoints/withhttpendpointcallback.md) -- `method` -- Updates an HTTP endpoint via callback
    ```typescript
  withHttpEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise<void>, name?: string, createIfNotExists?: boolean): IResourceWithEndpoints
  ```
- [withHttpHealthCheck](/reference/api/typescript/aspire.hosting/iresourcewithendpoints/withhttphealthcheck.md) -- `method` -- Adds a health check to the resource which is mapped to a specific endpoint.
    ```typescript
  withHttpHealthCheck(path?: string, statusCode?: number, endpointName?: string): IResourceWithEndpoints
  ```
- [withHttpProbe](/reference/api/typescript/aspire.hosting/iresourcewithendpoints/withhttpprobe.md) -- `method` -- Adds an HTTP health probe to the resource
    ```typescript
  withHttpProbe(probeType: ProbeType, path?: string, initialDelaySeconds?: number, periodSeconds?: number, timeoutSeconds?: number, failureThreshold?: number, successThreshold?: number, endpointName?: string): IResourceWithEndpoints
  ```
- [withHttpsEndpoint](/reference/api/typescript/aspire.hosting/iresourcewithendpoints/withhttpsendpoint.md) -- `method` -- Adds an HTTPS endpoint
    ```typescript
  withHttpsEndpoint(port?: number, targetPort?: number, name?: string, env?: string, isProxied?: boolean): IResourceWithEndpoints
  ```
- [withHttpsEndpointCallback](/reference/api/typescript/aspire.hosting/iresourcewithendpoints/withhttpsendpointcallback.md) -- `method` -- Updates an HTTPS endpoint via callback
    ```typescript
  withHttpsEndpointCallback(callback: (obj: EndpointUpdateContext) => Promise<void>, name?: string, createIfNotExists?: boolean): IResourceWithEndpoints
  ```
- [withMcpServer](/reference/api/typescript/aspire.hosting/iresourcewithendpoints/withmcpserver.md) -- `method` -- Marks the resource as hosting a Model Context Protocol (MCP) server on the specified endpoint.
    ```typescript
  withMcpServer(path?: string, endpointName?: string): IResourceWithEndpoints
  ```
