aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-06 14:54:12 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-06 14:54:12 +0100
commitf1886fb200406a6433669649c4f2448904876ec2 (patch)
tree807704c40ba487af8230ab83d4a0f4dcd49a2da9
parente904bbbca32614da95384d11f6ad5e53ea1e0036 (diff)
Fixed parameter processing for passthrough api.
-rw-r--r--lib/agent/xdsserver.go16
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