diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-11-06 14:54:12 +0100 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-11-06 14:54:12 +0100 |
commit | f1886fb200406a6433669649c4f2448904876ec2 (patch) | |
tree | 807704c40ba487af8230ab83d4a0f4dcd49a2da9 /lib/agent/xdsserver.go | |
parent | e904bbbca32614da95384d11f6ad5e53ea1e0036 (diff) |
Fixed parameter processing for passthrough api.
Diffstat (limited to 'lib/agent/xdsserver.go')
-rw-r--r-- | lib/agent/xdsserver.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/agent/xdsserver.go b/lib/agent/xdsserver.go index 5851a07..37604b5 100644 --- a/lib/agent/xdsserver.go +++ b/lib/agent/xdsserver.go @@ -251,7 +251,13 @@ func (xs *XdsServer) PassthroughGet(url string) { xs.apiRouter.GET(url, func(c *gin.Context) { var data interface{} - if err := xs._HTTPGet(url, &data); err != nil { + // Take care of param (eg. id in /projects/:id) + nURL := url + if strings.Contains(url, ":") { + nURL = strings.TrimPrefix(c.Request.URL.Path, xs.APIURL) + } + // Send Get request + if err := xs._HTTPGet(nURL, &data); err != nil { if strings.Contains(err.Error(), "connection refused") { xs.Connected = false xs._NotifyState() @@ -279,7 +285,13 @@ func (xs *XdsServer) PassthroughPost(url string) { return } - response, err := xs._HTTPPost(url, bodyReq[:n]) + // Take care of param (eg. id in /projects/:id) + nURL := url + if strings.Contains(url, ":") { + nURL = strings.TrimPrefix(c.Request.URL.Path, xs.APIURL) + } + // Send Post request + response, err := xs._HTTPPost(nURL, bodyReq[:n]) if err != nil { common.APIError(c, err.Error()) return |