aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCollin Guarino <collin.guarino@gmail.com>2016-01-25 20:49:19 -0500
committerCollin Guarino <collin.guarino@gmail.com>2016-01-25 20:49:19 -0500
commitd339d6e37fb3522623fb1f0b96c2005de5a27a63 (patch)
treea26ec0295bdbf322a5d67bd5eefe9c3c5a993a34
parent8392337305e5d5a3bb287ec62f212a8b64df95fb (diff)
Base implementation for CreateUser function.
-rw-r--r--bridge.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/bridge.go b/bridge.go
index 90f7719..739bf73 100644
--- a/bridge.go
+++ b/bridge.go
@@ -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) {