Ejemplo n.º 1
0
func All(rw http.ResponseWriter, req *http.Request, r render.Render) {
	ctx := appengine.NewContext(req)
	eq, err := equipment.All(ctx)
	if err != nil {
		http.Error(rw, err.Error(), http.StatusInternalServerError)
		return
	}
	if eq == nil {
		eq = make([]equipment.Equipment, 0)
	}

	r.JSON(200, eq)
}
Ejemplo n.º 2
0
func Index(rw http.ResponseWriter, req *http.Request, r render.Render) {
	c := appengine.NewContext(req)

	eq, err := equipment.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["Equipment"] = eq
	bag["ActiveNav"] = "equipment"
	r.HTML(200, "admin/equipment/index", bag)

	return
}