Skip to content

Commit

Permalink
switch additional headers to kv
Browse files Browse the repository at this point in the history
  • Loading branch information
jrcichra committed Oct 29, 2023
1 parent 89d8d70 commit cddfd79
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions gps_collector/gps_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"os"
"path/filepath"
"strconv"
"strings"
"time"

"github.com/joncrlsn/dque"
Expand All @@ -25,10 +24,10 @@ type GPSDConfig struct {
}

type IngestdConfig struct {
URL string `yaml:"url"`
Database string `yaml:"database"`
Table string `yaml:"table"`
AdditionalHeaders []string `yaml:"additional_headers"`
URL string `yaml:"url"`
Database string `yaml:"database"`
Table string `yaml:"table"`
AdditionalHeaders map[string]string `yaml:"additional_headers"`
}

type Config struct {
Expand Down Expand Up @@ -141,9 +140,8 @@ func queueToPost(q *dque.DQue, h *http.Client, cfg *Config) {
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("User-Agent", "gps-collector")
for _, header := range cfg.IngestdConfig.AdditionalHeaders {
kv := strings.SplitN(header, "=", 2)
req.Header.Set(kv[0], kv[1])
for key, value := range cfg.IngestdConfig.AdditionalHeaders {
req.Header.Set(key, value)
}

resp, err := h.Do(req)
Expand Down

0 comments on commit cddfd79

Please sign in to comment.