tyk://
prefix instead of http://
.
For example, if GET /status/200
is configured to be an Internal Endpoint on the listen path http://my-tyk-install.org/my-api/
then external calls to this endpoint will be rejected with HTTP 403 Forbidden
. Other APIs on Tyk will be able to direct traffic to this endpoint by setting their target_url
to tyk://my-api/status/200
.
tyk://{identifier}/{endpoint}
.
The options for the identifier
are:
self
(only if the endpoint is in the same API)api_id
(the unique API Identifier assigned to the API within Tyk)api_id | listen path | Endpoint 1 | Endpoint 2 (with internal endpoint middleware) |
---|---|---|---|
f1c63fa5177de2719 | /api1 | endpoint1_ext | endpoint1_int |
2e90b33a879945918 | /api2 | endpoint2_ext | endpoint2_int |
/api1/endpoint1_int
will be rejected with HTTP 403 Forbidden
, since this is an internal endpoint.
This endpoint could, however, be called from within either endpoint in /api2
as either:
tyk://api1/endpoint1_int
tyk://f1c63fa5177de2719/endpoint1_int
/api1/endpoint1_ext
as:
tyk://api1/endpoint1_int
tyk://f1c63fa5177de2719/endpoint1_int
tyk://self/endpoint1_int
operationId
defined in the OpenAPI Document that declares both the path and method for which the middleware should be added. Endpoint paths
entries (and the associated operationId
) can contain wildcards in the form of any string bracketed by curly braces, for example /status/{code}
. These wildcards are so they are human readable and do not translate to variable names. Under the hood, a wildcard translates to the “match everything” regex of: (.*)
.
The internal endpoint middleware (internal
) can be added to the operations
section of the Tyk OAS Extension (x-tyk-api-gateway
) in your Tyk OAS API Definition for the appropriate operationId
(as configured in the paths
section of your OpenAPI Document).
The internal
object has the following configuration:
enabled
: enable the middleware for the endpointGET /anything
endpointGET /redirect
endpointGET /example-internal-endpoint/anything
will be rejected, with Tyk returning HTTP 403 Forbidden
, since the /anything
endpoint is internal.
Any calls made to GET /example-internal-endpoint/redirect
will be redirected to GET /example-internal-endpoint/anything
. These will be proxied to the upstream because they originate from within Tyk Gateway (i.e. they are internal requests) - so the response from GET http://httpbin.org/anything
will be returned.
The configuration above is a complete and valid Tyk OAS API Definition that you can import into Tyk to try out the internal endpoint middleware.
internal
object to the extended_paths
section of your API definition.
The internal
object has the following configuration:
path
: the endpoint pathmethod
: the endpoint HTTP methodGET
requests to the /status/200
endpoint. Any requests made to this endpoint that originate externally to Tyk will be rejected with HTTP 403 Forbidden
. Conversely, the endpoint can be reached internally by another API at tyk://<listen_path>/status/200
.
internal
object to the extended_paths
section of your API definition.
In the example below the internal endpoint middleware has been configured for HTTP GET
requests to the /status/200
endpoint. Any requests made to this endpoint that originate externally to Tyk will be rejected with HTTP 403 Forbidden
. Conversely, the endpoint can be reached internally by another API at tyk://<listen_path>/status/200
.