# IResourceWithEndpoints

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

## 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;
  withExternalHttpEndpoints(): IResourceWithEndpoints;
  withHttpEndpoint(
      port?: number,
      targetPort?: number,
      name?: string,
      env?: string,
      isProxied?: 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;
  withMcpServer(
      path?: string,
      endpointName?: string): IResourceWithEndpoints;
  withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise<ResourceUrlAnnotation>): IResourceWithEndpoints;
}
```

## Methods

- [asHttp2Service](/reference/api/typescript/aspire.hosting/iresourcewithendpoints/ashttp2service.md) -- `method` -- Configures resource for HTTP/2
    ```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
  ```
- [withExternalHttpEndpoints](/reference/api/typescript/aspire.hosting/iresourcewithendpoints/withexternalhttpendpoints.md) -- `method` -- Makes HTTP endpoints externally accessible
    ```typescript
  withExternalHttpEndpoints(): 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
  ```
- [withHttpHealthCheck](/reference/api/typescript/aspire.hosting/iresourcewithendpoints/withhttphealthcheck.md) -- `method` -- Adds an HTTP health check
    ```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
  ```
- [withMcpServer](/reference/api/typescript/aspire.hosting/iresourcewithendpoints/withmcpserver.md) -- `method` -- Configures an MCP server endpoint on the resource
    ```typescript
  withMcpServer(path?: string, endpointName?: string): IResourceWithEndpoints
  ```
- [withUrlForEndpointFactory](/reference/api/typescript/aspire.hosting/iresourcewithendpoints/withurlforendpointfactory.md) -- `method` -- Adds a URL for a specific endpoint via factory callback
    ```typescript
  withUrlForEndpointFactory(endpointName: string, callback: (arg: EndpointReference) => Promise<ResourceUrlAnnotation>): IResourceWithEndpoints
  ```
