diff options
-rw-r--r-- | bridge.go | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -57,9 +57,9 @@ func GetBridgeInfo(self *Bridge) { trace(fmt.Sprintf("Bridge status error: %d", response.StatusCode), nil) os.Exit(1) } + defer response.Body.Close() body, error := ioutil.ReadAll(response.Body) - defer response.Body.Close() if error != nil { trace("Error parsing bridge description xml.", nil) os.Exit(1) @@ -74,6 +74,17 @@ func GetBridgeInfo(self *Bridge) { self.Info = *data } +func CreateUser(bridge *Bridge, deviceType string) (string, error) { + uri := fmt.Sprintf("http://%s/api", bridge.IPAddress) + response, err := http.PostForm(uri, uurl.Values{"deviceType": deviceType}) + if err != nil { + // TODO: handle error + } + defer response.Body.Close + body, err := ioutil.ReadAll(response.Body) + fmt.Printf(string(body)) +} + // Log the date, time, file location, line number, and function. // Message can be "" or Err can be nil (not both) func trace(message string, err error) { |