28 lines
588 B
Go
28 lines
588 B
Go
package http
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"strings"
|
|
|
|
"git.lorenzzz.dev/lorenzhohermuth/home-assistant/internal/api"
|
|
"git.lorenzzz.dev/lorenzhohermuth/home-assistant/pkg/env"
|
|
)
|
|
|
|
func FireEvent(event string, eventBody string) {
|
|
reader := strings.NewReader(eventBody)
|
|
|
|
apiSpecs := api.GetApiSpecifications()
|
|
url := env.GetUrl() + apiSpecs.FireEvent + event
|
|
|
|
req, err := http.NewRequest("POST", url, reader)
|
|
req.Header.Add("Authorization", "Bearer "+env.GetToken())
|
|
|
|
client := &http.Client{}
|
|
response, err := client.Do(req)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
fmt.Println(response)
|
|
}
|