Skip to content

Commit c259cf3

Browse files
author
zoidbergwill
committed
Support config via query params
Closes #12
1 parent 86ff9f8 commit c259cf3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

main.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,28 @@ func handleRequest(defaultConfig *libhoney.Config, w http.ResponseWriter, req *h
227227
}
228228
return
229229
}
230+
// Load potential custom query parameters
231+
// e.g. API key, dataset name, and honeycomb host
232+
cfg := &libhoney.Config{}
233+
query := req.URL.Query()
234+
key := query.Get("key")
235+
if key != "" {
236+
cfg.APIKey = key
237+
} else {
238+
cfg.APIKey = defaultConfig.APIKey
239+
}
240+
dataset := query.Get("dataset")
241+
if dataset != "" {
242+
cfg.Dataset = dataset
243+
} else {
244+
cfg.Dataset = defaultConfig.Dataset
245+
}
246+
host := query.Get("host")
247+
if host != "" {
248+
cfg.APIHost = host
249+
} else {
250+
cfg.APIHost = defaultConfig.APIHost
251+
}
230252
if eventType == "Pipeline Hook" {
231253
fmt.Println("Received pipeline webhook:", string(body))
232254
handlePipeline(cfg, w, body)

0 commit comments

Comments
 (0)