Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ type Service struct {
}

var webhookSlackURL string = os.Getenv("SLACK_WEBHOOK_URL")
var dashboardEndpoint string = os.Getenv("DASHBOARD_ENDPOINT")

var services []*Service

//go:embed templates/* static/*
var templatesFS embed.FS

func checkURLResponse(s Service) (bool, error) {
// Send an HTTP GET request to the specified URL
Expand Down Expand Up @@ -108,9 +114,6 @@ func sendSlackNotification(message string) {
}
}

//go:embed templates/* static/*
var templatesFS embed.FS

func updateAckStatus(services []*Service, serviceName string, ack bool) {
for _, service := range services {
if service.Name == serviceName {
Expand All @@ -121,8 +124,6 @@ func updateAckStatus(services []*Service, serviceName string, ack bool) {
}
}

var services []*Service

func main() {
// Read the service.yaml file
yamlFile, err := os.ReadFile("config.yaml")
Expand Down Expand Up @@ -190,8 +191,8 @@ func main() {
}
})

http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
http.HandleFunc("/"+dashboardEndpoint, func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" && dashboardEndpoint == "" {
http.NotFound(w, r)
return
}
Expand Down