web.go.bak 373 B

12345678910111213141516171819
  1. package core
  2. import (
  3. "fmt"
  4. "net/http"
  5. "github.com/brutella/hc/accessory"
  6. )
  7. func powerToggle(w http.ResponseWriter, r *http.Request) {
  8. TogglePower()
  9. //os.Exit(0)
  10. }
  11. // WebInterface handles the prometheus scrape endpoint
  12. func WebInterface(acc accessory.Thermostat) {
  13. http.HandleFunc("/power", powerToggle(acc))
  14. http.ListenAndServe(fmt.Sprintf(":%d", 8192), nil)
  15. }