Ejemplo n.º 1
0
Archivo: mod.go Proyecto: 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)
}
Ejemplo n.º 2
0
Archivo: mod.go Proyecto: 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)
}