February 2018
Intermediate to advanced
340 pages
9h 43m
English
The headers in the http package are, in fact, represented as map[string][]string, and this way, the Header type must be handled. The preceding code shows how to set and read the header values. The important thing about the header is that the value of the header key is the string slice. So, each key in a header can contain multiple values.
The Set method of the Header type sets the one-item slice under the given key. On the other hand, the Add method appends the values to the slice.
Using the Get method will retrieve the first value from the slice under the given key. If the whole slice is needed, the Header needs to be handled as a map. The whole header key can be removed by using the Del method.
Read now
Unlock full access