From 8f2533149572445b7b8a1e49ae548a229c3b9384 Mon Sep 17 00:00:00 2001 From: Antoine Girard Date: Wed, 14 Aug 2019 18:02:09 +0200 Subject: [PATCH 1/2] Add body in request --- .gitignore | 3 ++- http.go | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index d969c09..a985b65 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /config.yml /config.json -examples/ \ No newline at end of file +examples/ +.idea \ No newline at end of file diff --git a/http.go b/http.go index 27c8b3a..85b2075 100644 --- a/http.go +++ b/http.go @@ -2,6 +2,7 @@ package cachet import ( "crypto/tls" + "github.com/Sirupsen/logrus" "io/ioutil" "net/http" "regexp" @@ -32,6 +33,7 @@ type HTTPMonitor struct { AbstractMonitor `mapstructure:",squash"` Method string + Body string ExpectedStatusCode int `mapstructure:"expected_status_code"` Headers map[string]string @@ -42,7 +44,7 @@ type HTTPMonitor struct { // TODO: test func (monitor *HTTPMonitor) test() bool { - req, err := http.NewRequest(monitor.Method, monitor.Target, nil) + req, err := http.NewRequest(monitor.Method, monitor.Target, strings.NewReader(monitor.Body)) for k, v := range monitor.Headers { req.Header.Add(k, v) } From eaa006cc837ab475b98378612dca03bda81bb5a1 Mon Sep 17 00:00:00 2001 From: Antoine Girard Date: Wed, 14 Aug 2019 18:04:37 +0200 Subject: [PATCH 2/2] Remove useless import --- http.go | 1 - 1 file changed, 1 deletion(-) diff --git a/http.go b/http.go index 85b2075..1d7cc0f 100644 --- a/http.go +++ b/http.go @@ -2,7 +2,6 @@ package cachet import ( "crypto/tls" - "github.com/Sirupsen/logrus" "io/ioutil" "net/http" "regexp"