Reputation: 257
Basically I just want to forward this request:
http://somehost:4321/api/v1/{uid}/profile
into this:
http://123.45.67.89:4321/api/{uid}/profile
I've done this in krakend.json:
{
"version": 2,
"timeout": "3000ms",
"cache_ttl": "300s",
"name": "myapi",
"output_encoding": "json",
"port": 4321,
"endpoints": [
{
"endpoint": "/api/v1/{uid}/profile",
"method": "GET",
"headers_to_pass": [ "*" ],
"querystring_params": [ "*" ],
"output_encoding": "no-op",
"concurrent_calls": 1,
"backend": [
{
"url_pattern": "/api/{uid}/profile",
"encoding": "no-op",
"host": [
"http://123.45.67.89:4321"
]
}
]
}
]
}
But ends up with error:
panic: wildcard route ':uid' conflicts with existing children in path '/api/v1/:uid/profile'
Any clue?
Upvotes: 0
Views: 2599
Reputation: 257
Its turn out that I've declared same pattern as endpoint:
{
"version": 2,
"timeout": "3000ms",
"cache_ttl": "300s",
"name": "myapi",
"output_encoding": "json",
"port": 4321,
"endpoints": [
{
"endpoint": "/api/v1/me/profile",
"method": "GET",
"headers_to_pass": [ "*" ],
"output_encoding": "no-op",
"concurrent_calls": 1,
"backend": [
{
"url_pattern": "/api/me/profile",
"encoding": "no-op",
"host": [
"http://123.45.67.89:4321"
]
}
]
},
{
"endpoint": "/api/v1/{uid}/profile",
"method": "GET",
"headers_to_pass": [ "*" ],
"querystring_params": [ "*" ],
"output_encoding": "no-op",
"concurrent_calls": 1,
"backend": [
{
"url_pattern": "/api/{uid}/profile",
"encoding": "no-op",
"host": [
"http://123.45.67.89:4321"
]
}
]
}
]
}
After changed into this, it works well:
{
"version": 2,
"timeout": "3000ms",
"cache_ttl": "300s",
"name": "myapi",
"output_encoding": "json",
"port": 4321,
"endpoints": [
{
"endpoint": "/api/v1/me/profile",
"method": "GET",
"headers_to_pass": [ "*" ],
"output_encoding": "no-op",
"concurrent_calls": 1,
"backend": [
{
"url_pattern": "/api/me/profile",
"encoding": "no-op",
"host": [
"http://123.45.67.89:4321"
]
}
]
},
{
"endpoint": "/api/v1/user/{uid}/profile",
"method": "GET",
"headers_to_pass": [ "*" ],
"querystring_params": [ "*" ],
"output_encoding": "no-op",
"concurrent_calls": 1,
"backend": [
{
"url_pattern": "/api/user/{uid}/profile",
"encoding": "no-op",
"host": [
"http://123.45.67.89:4321"
]
}
]
}
]
}
Regards.
Upvotes: 1