From af73a764e0c2b3ac5e98b69f09df7fd0f06468df Mon Sep 17 00:00:00 2001 From: PeiHsuanTsai Date: Wed, 6 Mar 2019 14:25:36 +0800 Subject: [PATCH] allow to attach the body in request --- http.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/http.go b/http.go index 27c8b3a..017d7c6 100644 --- a/http.go +++ b/http.go @@ -32,6 +32,7 @@ type HTTPMonitor struct { AbstractMonitor `mapstructure:",squash"` Method string + Body string ExpectedStatusCode int `mapstructure:"expected_status_code"` Headers map[string]string @@ -42,7 +43,8 @@ type HTTPMonitor struct { // TODO: test func (monitor *HTTPMonitor) test() bool { - req, err := http.NewRequest(monitor.Method, monitor.Target, nil) + bodyReader := strings.NewReader(monitor.Body) + req, err := http.NewRequest(monitor.Method, monitor.Target, bodyReader) for k, v := range monitor.Headers { req.Header.Add(k, v) }