Esempio n. 1
0
func initializing() {
	conn, err := sqlx.Connect("mysql", config.GetConfig().GetString("database.mysql"))
	if err != nil {
		fmt.Printf("mysql connect err: %+v\n", err)
	}
	db = conn
}
Esempio n. 2
0
func main() {
	defer func() {
		if err := recover(); err != nil {
			glog.V(1).Infof("ERROR: recover err:%+v", err)
		}
	}()

	defer glog.Flush()
	ticker := time.NewTicker(1000 * 1000 * 100)
	go func() {
		for _ = range ticker.C {
			glog.Flush()
		}
	}()
	defer ticker.Stop()
	flag.Parse()
	conf := config.GetConfig()
	fmt.Println(conf)
	app := cli.NewApp()
	app.Name = "haostudent server"
	app.Author = "Qianno.Xie"
	app.Version = "0.0.1"
	app.Usage = "haostudent [port] default 1314"
	app.EnableBashCompletion = true
	app.Action = func(c *cli.Context) {
		port := ":9000"
		m := router.NewRouter()
		fmt.Printf("c is %+v, m is %+v\n", c.Args().First(), m)
		if c.Args().First() != "" {
			port = ":" + c.Args().First()
		}
		m.RunOnAddr(port)
	}
	app.Run(os.Args)

}
Esempio n. 3
0
func (this *RegisterView) RegisterSkip(w http.ResponseWriter, r *http.Request) {
	t, _ := template.ParseFiles(config.GetConfig().GetString("haostudent.user.register"))
	t.Execute(w, nil)
}
Esempio n. 4
0
func (this *UserView) UserSkip(w http.ResponseWriter, r *http.Request, user string) {
	t, _ := template.ParseFiles(config.GetConfig().GetString("haostudent.user.index"))
	t.Execute(w, &User{user})
}
Esempio n. 5
0
func (this *LoginView) LoginSkip(w http.ResponseWriter, r *http.Request) {
	fmt.Printf("index View start\n")
	t, _ := template.ParseFiles(config.GetConfig().GetString("haostudent.user.login"))
	t.Execute(w, nil)
	fmt.Printf("index View end\n")
}