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


Golang gophercloud.BuildHeaders函數代碼示例

本文整理匯總了Golang中github.com/rackspace/rack/internal/github.com/rackspace/gophercloud.BuildHeaders函數的典型用法代碼示例。如果您正苦於以下問題:Golang BuildHeaders函數的具體用法?Golang BuildHeaders怎麽用?Golang BuildHeaders使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: ToObjectUpdateMap

// ToObjectUpdateMap formats a UpdateOpts into a map of headers.
func (opts UpdateOpts) ToObjectUpdateMap() (map[string]string, error) {
	h, err := gophercloud.BuildHeaders(opts)
	if err != nil {
		return nil, err
	}
	for k, v := range opts.Metadata {
		h["X-Object-Meta-"+k] = v
	}
	return h, nil
}
開發者ID:reaperzn,項目名稱:rack,代碼行數:11,代碼來源:requests.go

示例2: ToContainerCreateMap

// ToContainerCreateMap formats a CreateOpts into a map of headers.
func (opts CreateOpts) ToContainerCreateMap() (map[string]string, error) {
	h, err := gophercloud.BuildHeaders(opts)
	if err != nil {
		return nil, err
	}
	for k, v := range opts.Metadata {
		h["X-Container-Meta-"+k] = v
	}
	return h, nil
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:11,代碼來源:requests.go

示例3: ToObjectDownloadParams

// ToObjectDownloadParams formats a DownloadOpts into a query string and map of
// headers.
func (opts DownloadOpts) ToObjectDownloadParams() (map[string]string, string, error) {
	q, err := gophercloud.BuildQueryString(opts)
	if err != nil {
		return nil, "", err
	}
	h, err := gophercloud.BuildHeaders(opts)
	if err != nil {
		return nil, q.String(), err
	}
	return h, q.String(), nil
}
開發者ID:reaperzn,項目名稱:rack,代碼行數:13,代碼來源:requests.go

示例4: ToContainerUpdateMap

// ToContainerUpdateMap formats a CreateOpts into a map of headers.
func (opts UpdateOpts) ToContainerUpdateMap() (map[string]string, error) {
	h, err := gophercloud.BuildHeaders(opts)
	if err != nil {
		return nil, err
	}
	for k, v := range opts.Metadata {
		h["X-Container-Meta-"+k] = v
	}
	for _, k := range opts.DeleteMetadata {
		h["X-Remove-Container-Meta-"+k] = "true"
	}
	return h, nil
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:14,代碼來源:requests.go

示例5: ToAccountUpdateMap

// ToAccountUpdateMap formats an UpdateOpts into a map[string]string of headers.
func (opts UpdateOpts) ToAccountUpdateMap() (map[string]string, error) {
	headers, err := gophercloud.BuildHeaders(opts)
	if err != nil {
		return nil, err
	}
	for k, v := range opts.Metadata {
		headers["X-Account-Meta-"+k] = v
	}
	for _, k := range opts.DeleteMetadata {
		headers["X-Remove-Account-Meta-"+k] = "true"
	}
	return headers, err
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:14,代碼來源:delegate.go

示例6: ToObjectCopyMap

// ToObjectCopyMap formats a CopyOpts into a map of headers.
func (opts CopyOpts) ToObjectCopyMap() (map[string]string, error) {
	if opts.Destination == "" {
		return nil, fmt.Errorf("Required CopyOpts field 'Destination' not set.")
	}
	h, err := gophercloud.BuildHeaders(opts)
	if err != nil {
		return nil, err
	}
	for k, v := range opts.Metadata {
		h["X-Object-Meta-"+k] = v
	}
	return h, nil
}
開發者ID:reaperzn,項目名稱:rack,代碼行數:14,代碼來源:requests.go

示例7: ToObjectCreateLargeParams

// ToObjectCreateLargeParams formats a CreateLargeOpts into a query string and map of
// headers.
func (opts CreateLargeOpts) ToObjectCreateLargeParams() (map[string]string, string, error) {
	q, err := gophercloud.BuildQueryString(opts)
	if err != nil {
		return nil, "", err
	}
	h, err := gophercloud.BuildHeaders(opts)
	if err != nil {
		return nil, q.String(), err
	}

	for k, v := range opts.Metadata {
		h["X-Object-Meta-"+k] = v
	}

	return h, q.String(), nil
}
開發者ID:reaperzn,項目名稱:rack,代碼行數:18,代碼來源:requests.go

示例8: ToObjectCopyMap

// ToObjectCopyMap formats a CopyOpts into a map of headers.
func (opts CopyOpts) ToObjectCopyMap() (map[string]string, error) {
	h, err := gophercloud.BuildHeaders(opts)
	if err != nil {
		return nil, err
	}
	for k, v := range opts.Metadata {
		h["X-Object-Meta-"+k] = v
	}
	// `Content-Length` is required and a value of "0" is acceptable, but calling `gophercloud.BuildHeaders`
	// will remove the `Content-Length` header if it's set to 0 (or equivalently not set). This will add
	// the header if it's not already set.
	if _, ok := h["Content-Length"]; !ok {
		h["Content-Length"] = "0"
	}
	return h, nil
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:17,代碼來源:delegate.go

示例9: ToAccountGetMap

// ToAccountGetMap formats a GetOpts into a map[string]string of headers.
func (opts GetOpts) ToAccountGetMap() (map[string]string, error) {
	return gophercloud.BuildHeaders(opts)
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:4,代碼來源:requests.go


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