fix(proxy-backend): prefix routes with / if not present in config

This commit ensures that the default `pathRewrite` configuration for a proxy element is more resilient to the combination of whether:
- `route` is prefixed with `/`
- `pathPrefix` on the plugin is suffixed with `/` (which at present it will never be - see comments).

Signed-off-by: Brian Fox <brianhfox@gmail.com>
This commit is contained in:
Brian Fox
2021-04-27 12:38:31 +02:00
parent 6c38f5e920
commit cdb3426e56
4 changed files with 67 additions and 7 deletions
+6 -5
View File
@@ -36,7 +36,7 @@ Example:
```yaml
# in app-config.yaml
proxy:
'/simple-example': http://simple.example.com:8080
simple-example: http://simple.example.com:8080
'/larger-example/v1':
target: http://larger.example.com:8080/svc.v1
headers:
@@ -46,10 +46,11 @@ proxy:
```
Each key under the proxy configuration entry is a route to match, below the
prefix that the proxy plugin is mounted on. It must start with a slash. For
example, if the backend mounts the proxy plugin as `/proxy`, the above
configuration will lead to the proxy acting on backend requests to
`/api/proxy/simple-example/...` and `/api/proxy/larger-example/v1/...`.
prefix that the proxy plugin is mounted on. If it does not start with a slash,
one will be prefixed automatically. For example, if the backend mounts the proxy
plugin as `/proxy`, the above configuration will lead to the proxy acting on
backend requests to `/api/proxy/simple-example/...` and
`/api/proxy/larger-example/v1/...`.
The value inside each route is either a simple URL string, or an object on the
format accepted by