本文整理汇总了Golang中url.URL.RawQuery方法的典型用法代码示例。如果您正苦于以下问题:Golang URL.RawQuery方法的具体用法?Golang URL.RawQuery怎么用?Golang URL.RawQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类url.URL
的用法示例。
在下文中一共展示了URL.RawQuery方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ListRequest
func (p *Propolis) ListRequest(path string, marker string, maxEntries int, includeAll bool) (listresult *ListBucketResult, err os.Error) {
// set up the query string
var prefix string
// are we scanning a subdirectory or starting at the root?
if path != "" {
prefix = path + "/"
}
query := make(url.Values)
query.Add("prefix", prefix)
// are we scanning just a single directory or getting everything?
if !includeAll {
query.Add("delimiter", "/")
}
// are we continuing an earlier scan?
if marker != "" {
query.Add("marker", marker)
}
// restrict the maximum number of entries returned
query.Add("max-keys", strconv.Itoa(maxEntries))
u := new(url.URL)
*u = *p.Url
u.RawQuery = query.Encode()
// issue the request
var resp *http.Response
if resp, err = p.SendRequest("GET", false, "", u, nil, "", nil); err != nil {
return
}
if resp.Body != nil {
defer resp.Body.Close()
}
// parse the stuff we care about from the xml result
listresult = &ListBucketResult{}
if err = xml.Unmarshal(resp.Body, listresult); err != nil {
listresult = nil
return
}
return
}
示例2: query
func (s *SQS) query(queueUrl string, params map[string]string, resp interface{}) os.Error {
params["Timestamp"] = time.UTC().Format(time.RFC3339)
var url_ *url.URL
var err os.Error
var path string
if queueUrl != "" {
url_, err = url.Parse(queueUrl)
path = queueUrl[len(s.Region.SQSEndpoint):]
} else {
url_, err = url.Parse(s.Region.SQSEndpoint)
path = "/"
}
if err != nil {
return err
}
//url_, err := url.Parse(s.Region.SQSEndpoint)
//if err != nil {
// return err
//}
sign(s.Auth, "GET", path, params, url_.Host)
url_.RawQuery = multimap(params).Encode()
r, err := http.Get(url_.String())
if err != nil {
return err
}
defer r.Body.Close()
//dump, _ := http.DumpResponse(r, true)
//println("DUMP:\n", string(dump))
//return nil
if r.StatusCode != 200 {
return buildError(r)
}
err = xml.Unmarshal(r.Body, resp)
return err
}