From 7bf6c0d2cf29e71779696bd5217736316506a5ee Mon Sep 17 00:00:00 2001 From: Blerim Sheqa Date: Fri, 30 Dec 2016 13:32:56 +0100 Subject: [PATCH] Captre authentication error --- beater/http.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/beater/http.go b/beater/http.go index 28050d15..424ec6ba 100644 --- a/beater/http.go +++ b/beater/http.go @@ -2,6 +2,7 @@ package beater import ( "crypto/tls" + "errors" "fmt" "net/http" @@ -18,11 +19,10 @@ func requestURL(bt *Icingabeat, method, path string) (*http.Response, error) { } url := fmt.Sprintf("https://%s:%v%s", bt.config.Host, bt.config.Port, path) - request, err := http.NewRequest(method, url, nil) if err != nil { - logp.Info("Request:", err) + logp.Info("Request: %v", err) } request.Header.Add("Accept", "application/json") @@ -33,5 +33,10 @@ func requestURL(bt *Icingabeat, method, path string) (*http.Response, error) { return nil, err } + switch response.StatusCode { + case 401: + err = errors.New("Authentication failed for user " + bt.config.User) + } + return response, err }