本文整理汇总了Golang中url.URL.Query方法的典型用法代码示例。如果您正苦于以下问题:Golang URL.Query方法的具体用法?Golang URL.Query怎么用?Golang URL.Query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类url.URL
的用法示例。
在下文中一共展示了URL.Query方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: canonicalizedResource
func canonicalizedResource(url *url.URL) string {
var res string
// Strip any port declaration (443/80/8080/...)
host := first(strings.SplitN(url.Host, ":", 2))
if strings.HasSuffix(host, ".amazonaws.com") {
// Hostname bucket style, ignore (s3-eu-west.|s3.)amazonaws.com
parts := strings.SplitN(host, ".", -1)
if len(parts) > 3 {
res = res + "/" + strings.Join(parts[:len(parts)-3], ".")
}
} else if len(host) > 0 {
// CNAME bucket style
res = res + "/" + host
} else {
// Bucket as root element in path already
}
// RawPath will include the bucket if not in the host
res = res + strings.SplitN(url.RawPath, "?", 2)[0]
// Include a sorted list of query parameters that have
// special meaning to aws. These should stay decoded for
// the canonical resource.
var amz []string
for key, values := range url.Query() {
if amzQueryParams[key] {
for _, value := range values {
if value != "" {
amz = append(amz, key+"="+value)
} else {
amz = append(amz, key)
}
}
}
}
if len(amz) > 0 {
sort.Strings(amz)
res = res + "?" + strings.Join(amz, "&")
}
// All done.
return res
}