diff --git a/http.go b/http.go index 6978e45..854de95 100644 --- a/http.go +++ b/http.go @@ -154,3 +154,15 @@ func InternalServerError(w http.ResponseWriter, r *http.Request, err string) { SetContentType(w, "application/json") Error(w, r, http.StatusInternalServerError, err) } + +func SetHeader(r *http.Request, key, val string) { + r.Header.Set(key, val) +} + +func AddHeader(r *http.Request, key, val string) { + r.Header.Add(key, val) +} + +func GetHeader(r *http.Request, key string) string { + return r.Header.Get(key) +} diff --git a/string_util.go b/string_util.go index 51f1d1c..d495248 100644 --- a/string_util.go +++ b/string_util.go @@ -92,6 +92,16 @@ func StringSliceContains(slice []string, s string) bool { return false } +func SplitString(s, sep string) (res []string) { + parts := strings.Split(s, sep) + for _, p := range parts { + if p != "" { + res = append(res, p) + } + } + return res +} + // StringAt ... func StringAt(s string, index int) string { if len(s)-1 < index || index < 0 {