package api import ( "encoding/json" "io" ) type MessageContent struct { Body string `json:"body"` Format string `json:"format"` FormattedBody string `json:"formatted_body"` MsgType string `json:"msgtype"` } type NotificationRequest struct { Notification Notification `json:"notification"` } type Notification struct { EventId string `json:"event_id"` Content MessageContent `json:"content"` Id string `json:"id"` Prio string `json:"prio"` RoomId string `json:"room_id"` RoomName string `json:"room_name"` Sender string `json:"sender"` SenderDisplayName string `json:"sender_display_name"` Type string `json:"type"` } func ParseNotification(body io.ReadCloser) (Notification, error) { var request NotificationRequest err := json.NewDecoder(body).Decode(&request) notification := request.Notification if err != nil { return notification, err } return notification, err }