當前位置: 首頁>>代碼示例>>Golang>>正文


Golang googleapi.ResolveRelative函數代碼示例

本文整理匯總了Golang中github.com/coreos/fleet/Godeps/_workspace/src/code/google/com/p/google-api-go-client/googleapi.ResolveRelative函數的典型用法代碼示例。如果您正苦於以下問題:Golang ResolveRelative函數的具體用法?Golang ResolveRelative怎麽用?Golang ResolveRelative使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ResolveRelative函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Do

func (c *UnitStateListCall) Do() (*UnitStatePage, error) {
	var body io.Reader = nil
	params := make(url.Values)
	params.Set("alt", "json")
	if v, ok := c.opt_["machineID"]; ok {
		params.Set("machineID", fmt.Sprintf("%v", v))
	}
	if v, ok := c.opt_["nextPageToken"]; ok {
		params.Set("nextPageToken", fmt.Sprintf("%v", v))
	}
	if v, ok := c.opt_["unitName"]; ok {
		params.Set("unitName", fmt.Sprintf("%v", v))
	}
	urls := googleapi.ResolveRelative(c.s.BasePath, "state")
	urls += "?" + params.Encode()
	req, _ := http.NewRequest("GET", urls, body)
	googleapi.SetOpaque(req.URL)
	req.Header.Set("User-Agent", "google-api-go-client/0.5")
	res, err := c.s.client.Do(req)
	if err != nil {
		return nil, err
	}
	defer googleapi.CloseBody(res)
	if err := googleapi.CheckResponse(res); err != nil {
		return nil, err
	}
	var ret *UnitStatePage
	if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
		return nil, err
	}
	return ret, nil
	// {
	//   "description": "Retrieve a page of UnitState objects.",
	//   "httpMethod": "GET",
	//   "id": "fleet.UnitState.List",
	//   "parameters": {
	//     "machineID": {
	//       "location": "query",
	//       "type": "string"
	//     },
	//     "nextPageToken": {
	//       "location": "query",
	//       "type": "string"
	//     },
	//     "unitName": {
	//       "location": "query",
	//       "type": "string"
	//     }
	//   },
	//   "path": "state",
	//   "response": {
	//     "$ref": "UnitStatePage"
	//   }
	// }

}
開發者ID:ericcapricorn,項目名稱:fleet,代碼行數:56,代碼來源:v1-gen.go

示例2: Do

func (c *UnitsSetCall) Do() error {
	var body io.Reader = nil
	body, err := googleapi.WithoutDataWrapper.JSONReader(c.desiredunitstate)
	if err != nil {
		return err
	}
	ctype := "application/json"
	params := make(url.Values)
	params.Set("alt", "json")
	urls := googleapi.ResolveRelative(c.s.BasePath, "units/{name}")
	urls += "?" + params.Encode()
	req, _ := http.NewRequest("PUT", urls, body)
	req.URL.Path = strings.Replace(req.URL.Path, "{name}", url.QueryEscape(c.name), 1)
	googleapi.SetOpaque(req.URL)
	req.Header.Set("Content-Type", ctype)
	req.Header.Set("User-Agent", "google-api-go-client/0.5")
	res, err := c.s.client.Do(req)
	if err != nil {
		return err
	}
	defer googleapi.CloseBody(res)
	if err := googleapi.CheckResponse(res); err != nil {
		return err
	}
	return nil
	// {
	//   "description": "Set the desired state of a Unit.",
	//   "httpMethod": "PUT",
	//   "id": "fleet.Unit.Set",
	//   "parameterOrder": [
	//     "name"
	//   ],
	//   "parameters": {
	//     "name": {
	//       "location": "path",
	//       "required": true,
	//       "type": "string"
	//     }
	//   },
	//   "path": "units/{name}",
	//   "request": {
	//     "$ref": "DesiredUnitState"
	//   }
	// }

}
開發者ID:Jitendrakry,項目名稱:fleet,代碼行數:46,代碼來源:v1-alpha-gen.go


注:本文中的github.com/coreos/fleet/Godeps/_workspace/src/code/google/com/p/google-api-go-client/googleapi.ResolveRelative函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。