mirror of
https://github.com/gosticks/go-hue-interface.git
synced 2025-10-16 11:45:35 +00:00
update config
This commit is contained in:
parent
178bcba23b
commit
324bd287c7
30
bridge.go
Normal file
30
bridge.go
Normal 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
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user