aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCollin Guarino <collin.guarino@gmail.com>2016-02-17 22:53:41 -0500
committerCollin Guarino <collin.guarino@gmail.com>2016-02-17 22:53:41 -0500
commit069c45e6c273534799a1121cb751e273cb2086b7 (patch)
tree93b15575367643af0c57d8c96d9f3df8b9c57796
parentb52b2b77e142d0315683b0a4d7565527f1264524 (diff)
Changed more 'self' definition names to reflect the name of the struct.
-rw-r--r--bridge.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/bridge.go b/bridge.go
index 808fa4d..7236092 100644
--- a/bridge.go
+++ b/bridge.go
@@ -66,8 +66,8 @@ func (bridge *Bridge) Get(path string) ([]byte, io.Reader, error) {
// Bridge.Put sends an http PUT to the bridge with
// a body formatted with parameters (in a generic interface)
-func (self *Bridge) Put(path string, params interface{}) ([]byte, io.Reader, error) {
- uri := fmt.Sprintf("http://" + self.IPAddress + path)
+func (bridge *Bridge) Put(path string, params interface{}) ([]byte, io.Reader, error) {
+ uri := fmt.Sprintf("http://" + bridge.IPAddress + path)
client := &http.Client{}
data, err := json.Marshal(params)
@@ -87,7 +87,7 @@ func (self *Bridge) Put(path string, params interface{}) ([]byte, io.Reader, err
// bridge.Post sends an http POST to the bridge with
// a body formatted with parameters (in a generic interface)
-func (self *Bridge) Post(path string, params interface{}) ([]byte, io.Reader, error) {
+func (bridge *Bridge) Post(path string, params interface{}) ([]byte, io.Reader, error) {
// Add the params to the request
request, err := json.Marshal(params)
if err != nil {
@@ -97,17 +97,17 @@ func (self *Bridge) Post(path string, params interface{}) ([]byte, io.Reader, er
log.Println("\nSending POST body: ", string(request))
// Send the request and handle the response
- uri := fmt.Sprintf("http://" + self.IPAddress + path)
+ uri := fmt.Sprintf("http://" + bridge.IPAddress + path)
resp, err := http.Post(uri, "text/json", bytes.NewReader(request))
- if self.Error(resp, err) {
+ if bridge.Error(resp, err) {
return []byte{}, nil, nil
}
return HandleResponse(resp)
}
// Bridge.Delete sends an http DELETE to the bridge
-func (self *Bridge) Delete(path string) error {
- uri := fmt.Sprintf("http://" + self.IPAddress + path)
+func (bridge *Bridge) Delete(path string) error {
+ uri := fmt.Sprintf("http://" + bridge.IPAddress + path)
client := &http.Client{}
req, err := http.NewRequest("DELETE", uri, nil)
resp, err := client.Do(req)
@@ -140,7 +140,7 @@ func HandleResponse(resp *http.Response) ([]byte, io.Reader, error) {
}
// Bridge.Error handles all bridge response status errors
-func (self *Bridge) Error(resp *http.Response, err error) (bool) {
+func (bridge *Bridge) Error(resp *http.Response, err error) (bool) {
if err != nil {
trace("", err)
return true
@@ -167,8 +167,8 @@ func NewBridge(ip string, username string) (*Bridge, error) {
}
// GetBridgeInfo retreives the description.xml file from the bridge.
-func (self *Bridge) GetInfo() (BridgeInfo, error) {
- _, reader, err := self.Get("/description.xml")
+func (bridge *Bridge) GetInfo() (BridgeInfo, error) {
+ _, reader, err := bridge.Get("/description.xml")
if err != nil {
return BridgeInfo{}, err
}
@@ -177,7 +177,7 @@ func (self *Bridge) GetInfo() (BridgeInfo, error) {
if err != nil {
return BridgeInfo{}, err
}
- self.Info = data
+ bridge.Info = data
return data, nil
}