From: Sebastien Douheret Date: Mon, 6 Nov 2017 13:54:12 +0000 (+0100) Subject: Fixed parameter processing for passthrough api. X-Git-Tag: v1.0.0-rc1~25 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?p=src%2Fxds%2Fxds-agent.git;a=commitdiff_plain;h=f1886fb200406a6433669649c4f2448904876ec2 Fixed parameter processing for passthrough api. --- 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