Skip to content

Commit

Permalink
cosmetic
Browse files Browse the repository at this point in the history
  • Loading branch information
mwennrich committed Mar 29, 2023
1 parent 76bd9d0 commit 934151e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions alertlogger.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ func parse(payload []byte) (*alertGroup, error) {
return &d, nil
}

// print itearates over the alertgroup and prints all alerts in json format
// printJson prints all alerts in json format
func printJson(ag *alertGroup, m *sync.Mutex) {

m.Lock()
for _, alert := range ag.Alerts {
out := map[string]string{"status": alert.Status}
Expand All @@ -76,7 +75,7 @@ func printJson(ag *alertGroup, m *sync.Mutex) {
m.Unlock()
}

// print iterates over the alertgroup and prints all alerts as key value pairs
// printKV iterates over the alertgroup and prints all alerts as key value pairs
func printKV(ag *alertGroup, m *sync.Mutex) {
m.Lock()
for _, alert := range ag.Alerts {
Expand Down Expand Up @@ -104,14 +103,17 @@ func main() {

http.HandleFunc("/",func(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()

b, err := io.ReadAll(r.Body)
if err != nil {
panic(err)
}

ag, err := parse(b)
if err != nil {
panic(err)
}

if jsonOutput {
printJson(ag, &m)
} else {
Expand Down

0 comments on commit 934151e

Please sign in to comment.