basic refactor + new prototype

This commit is contained in:
Matej Kramny
2017-02-04 16:02:22 -08:00
parent aaecc1669a
commit e910807973
6 changed files with 145 additions and 81 deletions

20
http.go
View File

@@ -7,10 +7,30 @@ import (
"fmt"
"io/ioutil"
"net/http"
"regexp"
"strconv"
"time"
)
type HttpMonitor struct {
URL string `json:"url"`
Method string `json:"method"`
StrictTLS bool `json:"strict_tls"`
CheckInterval time.Duration `json:"interval"`
HttpTimeout time.Duration `json:"timeout"`
// Threshold = percentage
Threshold float32 `json:"threshold"`
ExpectedStatusCode int `json:"expected_status_code"`
// compiled to Regexp
ExpectedBody string `json:"expected_body"`
bodyRegexp *regexp.Regexp
}
type TCPMonitor struct{}
type ICMPMonitor struct{}
type DNSMonitor struct{}
func (monitor *CachetMonitor) makeRequest(requestType string, url string, reqBody []byte) (*http.Response, []byte, error) {
req, err := http.NewRequest(requestType, monitor.APIUrl+url, bytes.NewBuffer(reqBody))