Пример #1
0
// GetNote retrieves a note from the authorized User's Notebook by ID. The Note is written in JSON format to w.
func GetNote(w http.ResponseWriter, r *http.Request, c appengine.Context, notebook *tessernote.Notebook) {
	id := r.URL.Path[len(NotesURL):]
	note, err := notebook.Note(id, c)
	if err != nil {
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}
	reply, err := json.Marshal(note)
	if err != nil {
		c.Errorf("marshaling note (%#v): %s", note, err)
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	w.Write(reply)
}