Exemple #1
0
func All(rw http.ResponseWriter, req *http.Request, r render.Render) {
	ctx := appengine.NewContext(req)
	ts, err := testimonials.All(ctx)
	if err != nil {
		http.Error(rw, err.Error(), http.StatusInternalServerError)
		return
	}

	if ts == nil {
		ts = make([]testimonials.Testimonial, 0)
	}

	r.JSON(200, ts)
}
Exemple #2
0
func Index(rw http.ResponseWriter, req *http.Request, r render.Render) {
	c := appengine.NewContext(req)

	ts, err := testimonials.All(c)
	if err != nil {
		http.Redirect(rw, req, "/admin?error="+err.Error(), http.StatusFound)
		return
	}

	bag := make(map[string]interface{}, 0)
	bag["Host"] = req.URL.Host
	bag["Admin"] = true
	bag["Testimonials"] = ts
	bag["ActiveNav"] = "testimonials"
	r.HTML(200, "admin/testimonials/index", bag)

	return
}