+ return
+ })
+}
+
+// PassthroughPut Used to declare a route that sends directly a PUT request to XDS Server
+func (xs *XdsServer) PassthroughPut(url string) {
+ if xs.apiRouter == nil {
+ xs.Log.Errorf("apiRouter not set !")
+ return
+ }
+
+ xs.apiRouter.PUT(url, func(c *gin.Context) {
+ var err error
+ var data interface{}
+
+ // Get raw body
+ body, err := c.GetRawData()
+ if err != nil {
+ common.APIError(c, err.Error())
+ return
+ }
+
+ // 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 Put request
+ response, err := xs.client.HTTPPutWithRes(nURL, string(body))
+ if err != nil {
+ goto httpError
+ }
+ if response.StatusCode != 200 {
+ err = fmt.Errorf(response.Status)
+ return
+ }
+ err = json.Unmarshal(xs.client.ResponseToBArray(response), &data)
+ if err != nil {
+ goto httpError
+ }
+
+ c.JSON(http.StatusOK, data)
+ return
+
+ /* Handle error case */
+ httpError:
+ if strings.Contains(err.Error(), "connection refused") {
+ xs._Disconnected()
+ }
+ common.APIError(c, err.Error())
+ return