示例#1
0
文件: index.go 项目: nodeweb/examples
func Test(store *mysqlstore.MySQLStore, db *sql.DB) httpFunc {
	f := func(w http.ResponseWriter, r *http.Request) {
		m := "Hello World!"
		session, _ := store.Get(r, "xUser")
		fmt.Println("foo=", session.Values["foo"])
		fmt.Println("42=", session.Values)
		fmt.Fprint(w, m)
	}
	return f
}
示例#2
0
文件: index.go 项目: nodeweb/examples
func Index(store *mysqlstore.MySQLStore, db *sql.DB) httpFunc {
	f := func(w http.ResponseWriter, r *http.Request) {
		t, err := template.ParseFiles(viewUrl+"index.html", viewUrl+"header.html", viewUrl+"footer.html")
		fmt.Println("terr==", err)
		p := mydata(db)
		session, err := store.Get(r, "xUser")
		fmt.Println("BBB=", err)
		session.Values["foo"] = "bar"
		session.Values[42] = 43
		session.Save(r, w)

		t.Execute(w, p)
	}
	return f
}