Skip to content
Snippets Groups Projects
Commit 7d938bec authored by Sergey Yakubov's avatar Sergey Yakubov
Browse files

error if canot get db address

parent 8f7c8ac4
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ package discovery ...@@ -3,6 +3,7 @@ package discovery
import ( import (
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"errors"
) )
type DiscoveryAPI struct { type DiscoveryAPI struct {
...@@ -15,6 +16,9 @@ func (api *DiscoveryAPI) GetMongoDbAddress() (string, error) { ...@@ -15,6 +16,9 @@ func (api *DiscoveryAPI) GetMongoDbAddress() (string, error) {
if err != nil { if err != nil {
return "", err return "", err
} }
if resp.StatusCode!=http.StatusOK {
return "", errors.New("cannot get mongodb server, status: "+resp.Status)
}
defer resp.Body.Close() defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body) body, err := ioutil.ReadAll(resp.Body)
return string(body), err return string(body), err
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment