示例#1
0
文件: boards.go 项目: fortytw2/eden
// GetBoardPosts returns all the posts on a certain board
func GetBoardPosts(ds *datastore.Datastore) httprouter.Handle {
	return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
		posts, err := ds.GetBoardPostsByName(ps.ByName("board"), 0)
		if err != nil {
			util.JSONError(w, err, http.StatusInternalServerError)
			return
		}

		w.Header().Set("Content-Type", "application/json")
		json.NewEncoder(w).Encode(posts)
	}
}