Path based routing


#1

Hi,

I played around with tyk but was not able to configure the following (don’t know if it is possible). We have several microservices in our system that all together build our API. Each service is handling one part of the API.

The routing of the requests should be as follows:

GET api/input -> input.service/input
POST api/input -> input.service/input
GET api/output -> output.service/output
POST api/output -> output.service/output

Is it possible to build this routing behaivor with tyk?

Thank you for your help!


#2

Hi There,

Routing is at the domain level at the moment, so all reuests for a managed API go to the same host, there’s no way to dynamically modify the target based on the path.

You could register two APIs though and have them listen on /api/input/ and /api/output respectively, then use the access rights setting in an API key or Policy to let a single key access both managed APIs, to the outside world it would be a single API.

Hope that helps :smiley:

Cheers,
Martin


#3

Thanks for the fast reply. Is it then also possible to just whitelist some methods/paths on that endpoint. For example if I want to allow just the following three call on input:

GET /api/input
POST /api/input
GET /api/input/

Thanks for the help!


#4

yup, this can be done in the dashboard with the whitelist plugin on the path (see the endpoint designer).

or use the file based approach:

https://tyk.io/v1.9/api-management/api-definition-detail/#version-data-version-name-extended-paths-white-list:ddb483dfc5a8ac6303545f6b6c9d076f


#5

Nice, I will try that. Thanks!