Captre authentication error
This commit is contained in:
parent
6a5d635ea2
commit
7bf6c0d2cf
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue