I have multiple microservices which are accessible by clients through Ocelot
gateway. Inside configuration file there are properties to specify downstream host and port. This have to be done for EACH route.
The problem is that if the service's hostname or port changes, I will have to modify every single route associated with this particular service.
So, the question is, Is it possible to introduce ENV variable inside ocelot.json
configuration file? In that case I will have to modify only one ENV variable and all associated routes will be affected.
Here is my current configuration file (I'm using docker-compose
so service names are used as hosts):
"Routes": [
{
"UpstreamPathTemplate": "/api/v1/signIn",
"DownstreamPathTemplate": "/api/v1/signIn",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "identity-api",
"Port": 80
}
],
"SwaggerKey": "Identity"
},
{
"UpstreamPathTemplate": "/api/v1/validate",
"DownstreamPathTemplate": "/api/v1/validate",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "identity-api",
"Port": 80
}
],
"SwaggerKey": "Identity"
},
What I want:
"Routes": [
{
"UpstreamPathTemplate": "/api/v1/signIn",
"DownstreamPathTemplate": "/api/v1/signIn",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": {SERVICE_HOST},
"Port": {SERVICE_PORT}
}
],
"SwaggerKey": "Identity"
},
{
"UpstreamPathTemplate": "/api/v1/validate",
"DownstreamPathTemplate": "/api/v1/validate",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": {SERVICE_HOST},
"Port": {SERVICE_PORT}
}
],
"SwaggerKey": "Identity"
},