Пример #1
0
func postNotes(w rest.ResponseWriter, r *rest.Request) {
	userid := r.PathParam("userid")

	var confirmationBuffer bytes.Buffer
	err := fApi.api.SaveNotes(r.Body, &confirmationBuffer, userid)

	//log.Println("postSmbgs confirmation ", string(confirmationBuffer.Bytes()[:]))

	if err != nil {
		w.WriteHeader(http.StatusInternalServerError)
		jsonErr, _ := w.EncodeJson(err)
		w.WriteJson(jsonErr)
		return
	}
	w.WriteHeader(http.StatusCreated)
	w.(http.ResponseWriter).Write(confirmationBuffer.Bytes())
	return
}
Пример #2
0
func getNotes(w rest.ResponseWriter, r *rest.Request) {
	userid := r.PathParam("userid")

	var notesBuffer bytes.Buffer

	err := fApi.api.GetNotes(&notesBuffer, userid)

	//log.Println("getSmbgs ", string(smbgsBuffer.Bytes()[:]))

	if err != nil {
		w.WriteHeader(http.StatusInternalServerError)
		jsonErr, _ := w.EncodeJson(err)
		w.WriteJson(jsonErr)
		return
	}
	w.(http.ResponseWriter).Write(notesBuffer.Bytes())
	return
}