示例#1
0
文件: mod.go 项目: icub3d/home
// DeleteLink deletes the link for the given tag. The currently
// logged in user must own the link. Otherwise, an unauthorized error
// is returned.
func DeleteLink(w http.ResponseWriter, r *http.Request) {
	// Get the context.
	c := appengine.NewContext(r)

	// Get the Key.
	vars := mux.Vars(r)
	key := vars["key"]

	datastore.RunInTransaction(c, func(c appengine.Context) error {

		if !gorca.DeleteStringKeyAndAncestors(c, w, r, "Link", key) {
			return fmt.Errorf("deleting link and items")
		}

		gorca.WriteSuccessMessage(c, w, r)

		return nil

	}, nil)
}
示例#2
0
文件: mod.go 项目: liyu4/home
// DeleteRecipe deletes the recipe for the given tag. The currently
// logged in user must own the recipe. Otherwise, an unauthorized error
// is returned.
func DeleteRecipe(w http.ResponseWriter, r *http.Request) {
	// Get the context.
	c := appengine.NewContext(r)

	// Get the Key.
	vars := mux.Vars(r)
	key := vars["key"]

	datastore.RunInTransaction(c, func(c appengine.Context) error {

		if !gorca.DeleteStringKeys(c, w, r, []string{key}) {
			return fmt.Errorf("deleting recipe")
		}

		gorca.WriteSuccessMessage(c, w, r)

		return nil

	}, nil)
}