Esempio n. 1
0
func start(w http.ResponseWriter, r *http.Request) {
	pf := petfinder.NewPetFinder(w, r)
	if pf == nil {
		fmt.Fprintf(w, "%v\n", "error")
	}

	testpet := pf.GetPets("dog", "66067", 10)
	for i := 0; i < 10; i++ {
		fmt.Fprintf(w, "%v\n", testpet[i])
	}
}
Esempio n. 2
0
func detail(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	aeu := aeuser.Current(c)
	k := datastore.NewKey(c, "user", aeu.Email, 0, nil)

	var u user.User

	if err := datastore.Get(c, k, &u); err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	pf := petfinder.NewPetFinder(w, r)
	//fmt.Fprintf(w, "%v %v", r.FormValue("lucky"), u.Zip)
	foundPets := pf.GetPets("dog", u.Zip, 4)

	//fmt.Fprintf(w, "%v", foundPets)
	if err := detTmpls.Execute(w, foundPets); err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
	}
}
Esempio n. 3
0
func luckyStrike(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	aeu := aeuser.Current(c)
	k := datastore.NewKey(c, "user", aeu.Email, 0, nil)

	var u user.User

	if err := datastore.Get(c, k, &u); err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	pf := petfinder.NewPetFinder(w, r)
	//fmt.Fprintf(w, "%v %v", r.FormValue("lucky"), u.Zip)
	foundPet := pf.GetPet(r.FormValue("lucky"), u.Zip)
	foundPet.Description = html.UnescapeString(foundPet.Description)

	//fmt.Fprintf(w, "%v", foundPet)
	if err := resTmpls.Execute(w, foundPet); err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
	}
}