Configure Endpoints¶
Services and integrations are exposed to other services, integrations, or applications through endpoints. A service or an integration can expose multiple endpoints, each representing a unique entry point into the service. For example, a service may expose a REST API endpoint and a GraphQL endpoint, each providing different ways to interact with the service. Endpoints provide specific details for how the service or the integration can be consumed. For instance, the port number, protocol, and the schema such as open API specification (OAS) or GraphQL schema. By defining these details, endpoints make it possible for other services, integrations, and applications to discover and interact with the service in a standardized way.
Choreo defines endpoints by combining port binding, protocol, endpoint name, network visibility, endpoint schema, and additional protocol-related fields. The following table describes each attribute of an endpoint.
Field | Description |
---|---|
Name | A unique identifier for the endpoint within the service component. |
Port | The network port on which the endpoint is accessible. |
Type | The endpoint protocol. Supported protocols: REST, GraphQL, gRPC, WS, UDP, and TCP. |
Network Visibility | Determines the level of visibility of an endpoint. Possible values are:
|
Schema | Specifies the structure and format of the data exchanged through the endpoint. |
Context (HTTP and GraphQL only) | A context path that you add to the endpoint's URL for routing purposes. |
Configure endpoints¶
The method of defining endpoints depends on the buildpack. For buildpacks other than Ballerina
and WSO2 MI
, it is required to have an component.yaml
file in project root directory to create the Service component.
Configure endpoints with buildpacks (except Ballerina)¶
When you build a service component using any other buildpacks(Java, Python, NodeJS, Ruby, PHP, Go, Dockerfile, etc) other than Ballerina and WSO2 MI, you can configure the endpoint details with the component.yaml
source configuration file. You must place this file inside the .choreo
directory at the build context path and commit it to the source repository.
To learn about the component.yaml
file, see Overview of the component.yaml file.
Configure endpoints with the Ballerina buildpack¶
When you create a service component with the Ballerina buildpack
, Choreo automatically detects the endpoint details for REST APIs. You can override the auto-generated endpoint configuration by providing the component.yaml
file in the source directory.
Note
Automatic endpoint generation is not supported for dynamic endpoint parameters such as variable ports. Therefore, you must use an component.yaml
file to define dynamic endpoint parameters.
To learn about the component.yaml
file, see Overview of the component.yaml file.
Expose endpoints as managed APIs¶
Exposing endpoints as managed APIs is crucial to ensure secure and controlled access to the services being exposed. When a user wants to expose their written service to the outside world or to the organization at large, there is an inherent security risk involved. To mitigate this risk, the Choreo platform is built with an internal (access within the organization only) or external (publicly accessible) gateway that is protected with Choreo API management making the services secure by design.
Note
This feature is not available for gRPC, UDP, and TCP endpoints.
If you want to expose an endpoint as a managed API in Choreo, you need to set the network visibility to either Organization or Public. This allows the endpoint to be exposed through the Choreo API Gateway, which provides a number of benefits, including:
- Expose APIs to external and internal consumers
- Full lifecycle API Management
- API throttling
- Secure APIs with industry-standard authorization flows
- API analytics and monitoring
Once you deploy the service component, Choreo will expose the endpoint as a managed API through the Choreo API Gateway. You can then use the full lifecycle API management features provided by Choreo to test, deploy, maintain, monitor, and manage your API using the API management features.
Understand the default component URL¶
The default URL of a component corresponds to the default endpoint of the component and is structured as follows:
<domain>/<project-name>/<component-name>
This URL does not include the default endpoint name. For all other endpoints, the URL structure includes the endpoint name, as follows:
<domain>/<project-name>/<component-name>/<endpoint-name>
If a component has multiple endpoints, Choreo allows you to change the endpoint corresponding to the default component URL. For a component with a single endpoint, the default URL automatically corresponds to that endpoint.
Change the default endpoint of a component¶
To change the default endpoint of a component, follow the steps given below:
Note
- You cannot change the default endpoint if it has associated published APIs. You must go to the Lifecycle page and unpublish the relevant APIs before updating the default endpoint. For instructions on unpublishing an API, see Lifecycle Management.
- Choreo does not allow you to change the default endpoint of a component if you create multiple deployment tracks within its current major version, or promote the component beyond its initial environment.
- Sign in to the Choreo Console.
- In the Component Listing pane, click on the component for which you want to change the default endpoint.
- In the left navigation menu, click Deploy.
- On the Deploy page, go to the Set Up card and click Configure & Deploy.
- In the Environment Configurations pane that opens, click Next.
- In the File Mount pane that opens, click Next.
- In the Endpoint Details pane that opens, click the Default Endpoint list, select the endpoint you want to set as the default endpoint, and then click Update.
- Click Deploy. This deploys the component with the selected endpoint as the default, and the default URL will now correspond to this endpoint.