Пример #1
0
func All(rw http.ResponseWriter, req *http.Request, r render.Render) {
	ctx := appengine.NewContext(req)
	bns, err := banner.All(ctx)
	if err != nil {
		http.Error(rw, err.Error(), http.StatusInternalServerError)
		return
	}

	if len(bns) == 0 {
		bns = make([]banner.Banner, 0)
	}

	r.JSON(200, bns)
}
Пример #2
0
func Index(rw http.ResponseWriter, req *http.Request, r render.Render) {
	c := appengine.NewContext(req)

	bns, err := banner.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["Banners"] = bns
	bag["ActiveNav"] = "banners"
	r.HTML(200, "admin/banners/index", bag)

	return
}