Captre authentication error

This commit is contained in:
Blerim Sheqa 2016-12-30 13:32:56 +01:00
parent 6a5d635ea2
commit 7bf6c0d2cf
1 changed files with 7 additions and 2 deletions

View File

@ -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
}