Skip to content

Commit

Permalink
add usage and nil check
Browse files Browse the repository at this point in the history
  • Loading branch information
liuqi committed Jan 30, 2015
1 parent cdaa672 commit 5b049d9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
usage:

codis-ha --codis-config=localhost:18087 --productName=test


2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type fnHttpCall func(objPtr interface{}, api string, method string, arg interfac
type aliveCheckerFactory func(addr string, defaultTimeout time.Duration) AliveChecker

var (
apiServer = flag.String("apiserver", "localhost:18087", "api server address")
apiServer = flag.String("codis-config", "localhost:18087", "api server address")
productName = flag.String("productName", "test", "product name, can be found in codis-proxy's config")

callHttp fnHttpCall = httpCall
Expand Down
6 changes: 5 additions & 1 deletion rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@ func httpCall(objPtr interface{}, url string, method string, arg interface{}) er
return errors.Errorf("error: %d, message: %s", resp.StatusCode, string(msg))
}

return json.NewDecoder(resp.Body).Decode(objPtr)
if objPtr != nil {
return json.NewDecoder(resp.Body).Decode(objPtr)
}

return nil
}

0 comments on commit 5b049d9

Please sign in to comment.