Exemple #1
0
func Heading(rw http.ResponseWriter, req *http.Request) {
	ctx := appengine.NewContext(req)

	heading, err := quote.GetHeading(ctx)
	if err != nil {
		http.Error(rw, err.Error(), http.StatusInternalServerError)
		return
	}

	rw.Header().Set("Content-Type", "text/plain")
	rw.Write([]byte(heading.Heading))

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

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

	heading, _ := quote.GetHeading(ctx)

	bag := make(map[string]interface{}, 0)
	bag["Host"] = req.URL.Host
	bag["Admin"] = true
	bag["Quotes"] = quotes
	bag["Heading"] = heading
	bag["ActiveNav"] = "quotes"
	r.HTML(200, "admin/quote/index", bag)

	return
}