update config

This commit is contained in:
Wlad Meixner 2019-02-09 16:46:17 +01:00
parent 178bcba23b
commit 324bd287c7
2 changed files with 33 additions and 2 deletions

30
bridge.go Normal file
View File

@ -0,0 +1,30 @@
package main
import (
"bytes"
"encoding/json"
"net/http"
)
type Bridge struct {
Config *Config
}
func (b *Bridge) postToBridge(endpoint string, payload interface{}) (interface{}, error) {
data, errMarhshal := json.Marshal(payload)
if errMarhshal != nil {
return nil, errMarhshal
}
req, err := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(data))
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
res, err := client.Do(req)
if err != nil {
return nil, err
}
return res, nil
}

View File

@ -2,6 +2,7 @@ package main
// Config hue api config
type Config struct {
Username string `yaml:name`
Password string `yaml:userpassword`
Username string `yaml:name`
Password string `yaml:userpassword`
BridgeAddr string `yaml:bridgeAddress`
}