func GetNotificationDocument()

in HttpUtils.go [16:43]


func GetNotificationDocument(w http.ResponseWriter, req *http.Request) (*VSNotificationDocument, *[]byte) {
	if req.Method != "POST" {
		w.Header().Add("Content-Type", "application/json")
		resp := GenericResponse{Status: "error", Detail: "Expected a POST"}
		responseBytes, _ := json.Marshal(resp)

		w.WriteHeader(405)
		io.Copy(w, bytes.NewReader(responseBytes))
		return nil, nil
	}

	bodyContent, readErr := ioutil.ReadAll(req.Body)
	if readErr != nil {
		log.Print("ERROR VidispineMessageHandler could not read content sent by server: ", readErr)
		w.WriteHeader(400)
		return nil, nil
	}

	var notification VSNotificationDocument
	parseErr := json.Unmarshal(bodyContent, &notification)
	if parseErr != nil {
		log.Printf("ERROR Could not parse content from server (expecting JSON). Offending content was: ")
		log.Printf(string(bodyContent))
		w.WriteHeader(400)
		return nil, nil
	}
	return &notification, &bodyContent
}