aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinhies <inhies@github.com>2016-11-03 11:53:03 -0600
committerinhies <inhies@github.com>2016-11-03 11:53:03 -0600
commitabcaf8ba7f9caf56897360a5a2d7754c7b27f82e (patch)
tree797a59af8bf2e371924c67ccdd3aa9116e7bc3c8
parentbcedaebe4944b242d7ffbee27591170e22cbc0a9 (diff)
Go fmt bridge.go
-rw-r--r--bridge.go36
1 files changed, 18 insertions, 18 deletions
diff --git a/bridge.go b/bridge.go
index 2a6fb26..9502af7 100644
--- a/bridge.go
+++ b/bridge.go
@@ -92,17 +92,17 @@ func (bridge *Bridge) Put(path string, params interface{}) ([]byte, io.Reader, e
// a body formatted with parameters (in a generic interface).
// If `params` is nil then it will send an empty body with the post request.
func (bridge *Bridge) Post(path string, params interface{}) ([]byte, io.Reader, error) {
- // Add the params to the request or allow an empty body
- request := []byte{}
- if params != nil {
- reqBody, err := json.Marshal(params)
- if err != nil {
- err = errors.New("Error: Unable to add POST body parameters due to json marshal error.")
- log.Println(err)
- return []byte{}, nil, err
- }
- request = reqBody
- }
+ // Add the params to the request or allow an empty body
+ request := []byte{}
+ if params != nil {
+ reqBody, err := json.Marshal(params)
+ if err != nil {
+ err = errors.New("Error: Unable to add POST body parameters due to json marshal error.")
+ log.Println(err)
+ return []byte{}, nil, err
+ }
+ request = reqBody
+ }
// Send the request and handle the response
uri := fmt.Sprintf("http://" + bridge.IPAddress + path)
resp, err := http.Post(uri, "text/json", bytes.NewReader(request))
@@ -111,7 +111,7 @@ func (bridge *Bridge) Post(path string, params interface{}) ([]byte, io.Reader,
log.Println(err)
return []byte{}, nil, err
}
- return HandleResponse(resp)
+ return HandleResponse(resp)
}
// Bridge.Delete sends an http DELETE to the bridge
@@ -134,7 +134,7 @@ func (bridge *Bridge) Delete(path string) error {
// and invalid return types.
func HandleResponse(resp *http.Response) ([]byte, io.Reader, error) {
body, err := ioutil.ReadAll(resp.Body)
- defer resp.Body.Close()
+ defer resp.Body.Close()
if err != nil {
trace("Error parsing bridge description xml.", nil)
return []byte{}, nil, err
@@ -162,11 +162,11 @@ func FindBridges() ([]Bridge, error) {
log.Fatal(err)
return []Bridge{}, err
}
- bridges := []Bridge{}
- err = json.Unmarshal(body, &bridges)
- if err != nil {
- return []Bridge{}, errors.New("Unable to parse FindBridges response. ")
- }
+ bridges := []Bridge{}
+ err = json.Unmarshal(body, &bridges)
+ if err != nil {
+ return []Bridge{}, errors.New("Unable to parse FindBridges response. ")
+ }
return bridges, nil
}