コード例 #1
0
func ShowController(w http.ResponseWriter, r *http.Request) {
	// TODO some kind of validation that the plan belongs to the user.
	// TODO if the plan doesn't exist, return 404
	id := getId(r)
	d := make(map[string]interface{})
	d["plan"] = plan.Find(id)
	w.Write(util.JSON(d))
}
コード例 #2
0
func UpdateController(w http.ResponseWriter, r *http.Request) {
	r.ParseForm()
	p := plan.Find(getId(r))
	updateAttributes(p, r)
	p.Save()
	d := make(map[string]interface{})
	if p.Save() {
		d["job"] = p
	}
	w.Write(util.JSON(d))
}
コード例 #3
0
func DeleteController(w http.ResponseWriter, r *http.Request) {
	// TODO 404 if no job
	p := plan.Find(getId(r))
	p.Delete()
	w.Write(util.JSON(make(map[string]interface{})))
}