marshalCustomHeaders encodes a map of custom headers to JSON for database storage. A nil map produces an empty JSON object.
(headers map[string]string)
| 1300 | // marshalCustomHeaders encodes a map of custom headers to JSON for |
| 1301 | // database storage. A nil map produces an empty JSON object. |
| 1302 | func marshalCustomHeaders(headers map[string]string) (string, error) { |
| 1303 | if headers == nil { |
| 1304 | return "{}", nil |
| 1305 | } |
| 1306 | encoded, err := json.Marshal(headers) |
| 1307 | if err != nil { |
| 1308 | return "", err |
| 1309 | } |
| 1310 | return string(encoded), nil |
| 1311 | } |
| 1312 | |
| 1313 | // trimStringSlice trims whitespace from each element and drops empty |
| 1314 | // strings. |
no test coverage detected