terraform/vendor/github.com/mozillazg/go-httpheader
Li Kexian 76e5b446ba
backend/cos: Add TencentCloud backend cos with lock (#22540)
* add TencentCloud COS backend for remote state

* add vendor of dependence

* fixed error not handle and remove default value for prefix argument

* get appid from TF_COS_APPID environment variables
2020-02-13 11:37:11 -05:00
..
.bumpversion.cfg backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
.gitignore backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
.travis.yml backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
CHANGELOG.md backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
LICENSE backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
Makefile backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
README.md backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
encode.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
go.mod backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00

README.md

go-httpheader

go-httpheader is a Go library for encoding structs into Header fields.

Build Status Coverage Status Go Report Card GoDoc

install

go get -u github.com/mozillazg/go-httpheader

usage

package main

import (
	"fmt"
	"net/http"

	"github.com/mozillazg/go-httpheader"
)

type Options struct {
	hide         string
	ContentType  string `header:"Content-Type"`
	Length       int
	XArray       []string `header:"X-Array"`
	TestHide     string   `header:"-"`
	IgnoreEmpty  string   `header:"X-Empty,omitempty"`
	IgnoreEmptyN string   `header:"X-Empty-N,omitempty"`
	CustomHeader http.Header
}

func main() {
	opt := Options{
		hide:         "hide",
		ContentType:  "application/json",
		Length:       2,
		XArray:       []string{"test1", "test2"},
		TestHide:     "hide",
		IgnoreEmptyN: "n",
		CustomHeader: http.Header{
			"X-Test-1": []string{"233"},
			"X-Test-2": []string{"666"},
		},
	}
	h, _ := httpheader.Header(opt)
	fmt.Printf("%#v", h)
	// h:
	// http.Header{
	//	"X-Test-1":     []string{"233"},
	//	"X-Test-2":     []string{"666"},
	//	"Content-Type": []string{"application/json"},
	//	"Length":       []string{"2"},
	//	"X-Array":      []string{"test1", "test2"},
	//	"X-Empty-N":    []string{"n"},
	//}
}