Commit 3173b06a417a52edf5649e2234eaf09359a768f1

Authored by Marko Tikvić
1 parent a8f0d5a63e
Exists in master

SplitString()

Showing 2 changed files with 22 additions and 0 deletions   Show diff stats
... ... @@ -154,3 +154,15 @@ func InternalServerError(w http.ResponseWriter, r *http.Request, err string) {
154 154 SetContentType(w, "application/json")
155 155 Error(w, r, http.StatusInternalServerError, err)
156 156 }
  157 +
  158 +func SetHeader(r *http.Request, key, val string) {
  159 + r.Header.Set(key, val)
  160 +}
  161 +
  162 +func AddHeader(r *http.Request, key, val string) {
  163 + r.Header.Add(key, val)
  164 +}
  165 +
  166 +func GetHeader(r *http.Request, key string) string {
  167 + return r.Header.Get(key)
  168 +}
... ...
... ... @@ -92,6 +92,16 @@ func StringSliceContains(slice []string, s string) bool {
92 92 return false
93 93 }
94 94  
  95 +func SplitString(s, sep string) (res []string) {
  96 + parts := strings.Split(s, sep)
  97 + for _, p := range parts {
  98 + if p != "" {
  99 + res = append(res, p)
  100 + }
  101 + }
  102 + return res
  103 +}
  104 +
95 105 // StringAt ...
96 106 func StringAt(s string, index int) string {
97 107 if len(s)-1 < index || index < 0 {
... ...