Example #1
0
func Run() {
	if PprofOn {
		BeeApp.RegisterController(`/debug/pprof`, &ProfController{})
		BeeApp.RegisterController(`/debug/pprof/:pp([\w]+)`, &ProfController{})
	}
	if SessionOn {
		GlobalSessions, _ = session.NewManager(SessionProvider, SessionName, SessionGCMaxLifetime)
		go GlobalSessions.GC()
	}
	BeeApp.Run()
}
Example #2
0
File: beego.go Project: CMONO/beego
func Run() {
	if PprofOn {
		BeeApp.Router(`/debug/pprof`, &ProfController{})
		BeeApp.Router(`/debug/pprof/:pp([\w]+)`, &ProfController{})
	}
	if SessionOn {
		GlobalSessions, _ = session.NewManager(SessionProvider, SessionName, SessionGCMaxLifetime)
		go GlobalSessions.GC()
	}
	err := BuildTemplate(ViewsPath)
	if err != nil {
		Warn(err)
	}
	BeeApp.Run()
}
Example #3
0
//然后在init函数中初始化
func init() {
	globalSessions, _ = session.NewManager("memory", "gosessionid", 3600)
	go globalSessions.GC()
}
Example #4
0
	"strings"
)

type role struct {
	NonLogin bool
	IsAdmin  bool
}

type user struct {
	userID   uint32
	username string
	passwd   string
	permiss  uint32
}

var globalSessions, _ = session.NewManager("memory", "gosessionid", 0)

func Reg(w http.ResponseWriter, r *http.Request) {
	t, _ := template.ParseFiles("view/nav.html", "view/reg.html")

	if r.Method == "POST" {
		user := user{}
		tmp_username := strings.Trim(r.FormValue("username"), " ")
		tmp_username = template.HTMLEscapeString(tmp_username)
		if len(tmp_username) < 5 || len(tmp_username) > 50 {
			mainData(w, r, t, "reg", "用户名少于5位或大于50位")
			return
		}
		if m, _ := regexp.MatchString("^[a-zA-z]+[a-zA-Z0-9]*$", tmp_username); !m {
			mainData(w, r, t, "reg", "用户名只能以字母和数字的组合")
			return