Пример #1
0
func ListAPIView(w http.ResponseWriter, r *http.Request) {
	db, err := models.NewConnect(dbPath)
	defer db.Close()

	url := r.URL.Query().Get("url")
	c, err := models.AllComic(db, url)
	if err != nil || c == nil {
		fmt.Printf("%p", err)
		http.Error(w, http.StatusText(404), 404)
		return
	}
	jsonReponse(w, c, 200)
}
Пример #2
0
func ListView(w http.ResponseWriter, r *http.Request) {
	db, err := models.NewConnect(dbPath)
	defer db.Close()

	c, err := models.AllComic(db, "")
	if err != nil {
		fmt.Printf("%p", err)
		http.Error(w, http.StatusText(404), 404)
		return
	}
	type data struct {
		Comics []*models.Comic
	}
	renderTemplate(w, data{c}, "admin.html", "template/admin.html")
}