コード例 #1
0
ファイル: handlers.go プロジェクト: AbhiAgarwal/go-exps
func (c *appContext) tasksHandler(w http.ResponseWriter, r *http.Request) {
	repo := tasksModel.TaskRepo{c.db.C("tasks")}
	tasks, err := repo.All()
	if err != nil {
		panic(err)
	}

	w.Header().Set("Content-Type", "application/vnd.api+json")
	json.NewEncoder(w).Encode(tasks)
}