Skip to content

Commit

Permalink
unmarshal json
Browse files Browse the repository at this point in the history
  • Loading branch information
slamdev committed May 23, 2020
1 parent 65f7c80 commit 63cf13e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/notifier/events.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package notifier

import (
"encoding/json"
"github.com/sirupsen/logrus"
"io/ioutil"
"net/http"
)

func handleEventsRequest(w http.ResponseWriter, r *http.Request) {
event, err := ioutil.ReadAll(r.Body)
data, err := ioutil.ReadAll(r.Body)
if err != nil {
logrus.WithError(err).Info("failed to read request body")
}
logrus.WithField("event", string(event)).Info("received event")
event := make(map[string]interface{})
if err := json.Unmarshal(data, &event); err != nil {
logrus.WithError(err).WithField("data", string(data)).Error("failed to unmarshal json")
}
logrus.WithField("event", event).Info("received event")
}

0 comments on commit 63cf13e

Please sign in to comment.