Esempio n. 1
0
func TestHandler(w http.ResponseWriter, r *http.Request) {
	var p model.Post = model.Post{0, "Suave! Goddamn you're one suave f****r!", "You stay alive, baby. Do it for Van Gogh.", 1, true, time.Now(), time.Now()}
	var p2 model.Post = model.Post{0, "Test Post", "Heineken? F**k that shit! Pabst Blue Ribbon!", 1, true, time.Now(), time.Now()}
	posts := m{"p1": introspection.ConvertToMap(p), "p2": introspection.ConvertToMap(p2)}
	ctx := m{"posts": posts}
	RenderTemplate(w, "index", ctx)
}
Esempio n. 2
0
File: view.go Progetto: amaudy/Gooo
func HomeHandler(w http.ResponseWriter, r *http.Request, title string) {
	db := model.OpenConn()
	model.TestEmptyDB(db)
	var p model.Post = model.Post{model.M, 2, "Hello World", "whats up yo", 1, true, time.Now(), time.Now()}
	var p2 model.Post = model.Post{model.M, 2, "Test2", "another test post please ignore", 1, true, time.Now(), time.Now()}
	fmt.Println(p.ModelName())
	atts := introspection.GetStructValues(&p)
	model.InsertIntoDB(atts)
	model.GetPosts(10)
	posts := map[string]interface{}{"p1": introspection.ConvertToMap(p), "p2": introspection.ConvertToMap(p2)}
	ctx := map[string]interface{}{"posts": posts}
	defer db.Close()
	//defer stmt.Close()
	RenderTemplate(w, "index", ctx)
}
Esempio n. 3
0
File: view.go Progetto: amaudy/Gooo
func SaveHandler(w http.ResponseWriter, r *http.Request, title string) {
	content := r.FormValue("content")
	p := &model.Post{Title: title, Content: content, UserId: 1, Published: true, Created: time.Now(), Modified: time.Now()}
	p.Title = "lol"
	atts := introspection.GetStructValues(&p)
	model.InsertIntoDB(atts)
	ctx := map[string]interface{}{"post": introspection.ConvertToMap(p)}
	RenderTemplate(w, "post", ctx)
}