本文整理匯總了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"
// }
// }
}
示例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"
// }
// }
}