29 lines
571 B
Go
29 lines
571 B
Go
package server
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"sync"
|
|
|
|
"gitea.henriburau.de/ace966/WeeWooWebhook/internal/olc"
|
|
)
|
|
|
|
type Server struct {
|
|
OfficeLightClient *olc.OfficeLightClient
|
|
downServices map[int]bool
|
|
mu sync.Mutex
|
|
}
|
|
|
|
func NewServer(olc *olc.OfficeLightClient) *Server {
|
|
return &Server{
|
|
OfficeLightClient: olc,
|
|
downServices: make(map[int]bool),
|
|
}
|
|
}
|
|
|
|
func (s *Server) ListenAndServe() error {
|
|
fmt.Println("Server listening on :8085/wehook...")
|
|
http.HandleFunc("/webhook", s.webhookHandler())
|
|
return http.ListenAndServe(":8085", nil)
|
|
}
|