mirror of
https://gitlab1.ptb.de/waltem01/Matrix
synced 2024-12-26 12:01:45 +00:00
generic send instructions method
This commit is contained in:
parent
2e62aa5579
commit
90f577820e
17
main.go
17
main.go
@ -115,6 +115,20 @@ func LoadMatrixData() (string, int, int) {
|
|||||||
return url, width, height
|
return url, width, height
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SendRequest(client *resty.Client, url string, ins []interface{}) {
|
||||||
|
resp, err := client.R().
|
||||||
|
SetHeader("Content-Type", "application/json").
|
||||||
|
SetBody(ins).
|
||||||
|
Post(fmt.Sprintf("%s/instructions", url))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("Response Status: %s\n", resp.Status())
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Load .env file if it exists
|
// Load .env file if it exists
|
||||||
err := godotenv.Load(".env")
|
err := godotenv.Load(".env")
|
||||||
@ -132,4 +146,7 @@ func main() {
|
|||||||
col := Color{R: 255, G: 0, B: 255, endpoint: COLOR}
|
col := Color{R: 255, G: 0, B: 255, endpoint: COLOR}
|
||||||
rct := Rectangle{X: 0, Y: 0, W: 10, H: 10, endpoint: RECTANGLE}
|
rct := Rectangle{X: 0, Y: 0, W: 10, H: 10, endpoint: RECTANGLE}
|
||||||
upd := Update{endpoint: UPDATE}
|
upd := Update{endpoint: UPDATE}
|
||||||
|
|
||||||
|
// Send request to remote server
|
||||||
|
SendRequest(client, url, []interface{}{col, rct, upd})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user