aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/rs/cors/utils.go
blob: 429ab1114b9eeaf40a32b3d457fd6f9b0ccea342 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package cors

import (
    "net/http"
    "strings"
)

type converter func(string) string

// convert converts a list of string using the passed converter function
func convert(s []string, c converter) []string {
    out := []string{}
    for _, i := range s {
        out = append(out, c(i))
    }
    return out
}

func parseHeaderList(headerList string) (headers []string) {
    for _, header := range strings.Split(headerList, ",") {
        header = http.CanonicalHeaderKey(strings.TrimSpace(header))
        if header != "" {
            headers = append(headers, header)
        }
    }
    return headers
}