dsproxy: interpolate route url

Allows for dynamic urls for plugin routes. There are a few plugins
where the route url should be configurable and this change allows
using jsonData fields in the url field for a route in the
plugin.json file for a plugin.
This commit is contained in:
Daniel Lee
2018-08-18 16:00:40 +02:00
parent da2822c88d
commit c75e071213
2 changed files with 28 additions and 3 deletions
+8 -2
View File
@@ -320,9 +320,15 @@ func (proxy *DataSourceProxy) applyRoute(req *http.Request) {
SecureJsonData: proxy.ds.SecureJsonData.Decrypt(),
}
routeURL, err := url.Parse(proxy.route.Url)
interpolatedURL, err := interpolateString(proxy.route.Url, data)
if err != nil {
logger.Error("Error parsing plugin route url")
logger.Error("Error interpolating proxy url", "error", err)
return
}
routeURL, err := url.Parse(interpolatedURL)
if err != nil {
logger.Error("Error parsing plugin route url", "error", err)
return
}