Additional request header parameters for httpjson plugin

closes #471
This commit is contained in:
Andrea Sosso
2016-01-26 14:18:22 +01:00
committed by Cameron Sparr
parent c10227a766
commit f8930b9cbc
3 changed files with 30 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ type HttpJson struct {
Method string
TagKeys []string
Parameters map[string]string
Headers map[string]string
client HTTPClient
}
@@ -70,6 +71,12 @@ var sampleConfig = `
[inputs.httpjson.parameters]
event_type = "cpu_spike"
threshold = "0.75"
# HTTP Header parameters (all values must be strings)
# [inputs.httpjson.headers]
# X-Auth-Token = "my-xauth-token"
# apiVersion = "v1"
`
func (h *HttpJson) SampleConfig() string {
@@ -191,6 +198,11 @@ func (h *HttpJson) sendRequest(serverURL string) (string, float64, error) {
return "", -1, err
}
// Add header parameters
for k, v := range h.Headers {
req.Header.Add(k, v)
}
start := time.Now()
resp, err := h.client.MakeRequest(req)
if err != nil {