1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-15 05:31:02 +00:00

add some useful function

1. Router
2. SetSession/GetSession/DelSession
3. RenderString
4. str2html/htmlquote/htmlunquote
5. move the template Function to util.go
This commit is contained in:
astaxie
2013-04-03 23:37:59 +08:00
parent 74d8952c5a
commit 69f40ad18a
4 changed files with 197 additions and 131 deletions

View File

@ -153,7 +153,7 @@ func (app *App) Run() {
}
}
func (app *App) RegisterController(path string, c ControllerInterface) *App {
func (app *App) Router(path string, c ControllerInterface) *App {
app.Handlers.Add(path, c)
return app
}
@ -192,7 +192,12 @@ func (app *App) AccessLog(ctx *Context) {
}
func RegisterController(path string, c ControllerInterface) *App {
BeeApp.RegisterController(path, c)
BeeApp.Router(path, c)
return BeeApp
}
func Router(path string, c ControllerInterface) *App {
BeeApp.Router(path, c)
return BeeApp
}
@ -213,8 +218,8 @@ func FilterPrefixPath(path string, filter http.HandlerFunc) *App {
func Run() {
if PprofOn {
BeeApp.RegisterController(`/debug/pprof`, &ProfController{})
BeeApp.RegisterController(`/debug/pprof/:pp([\w]+)`, &ProfController{})
BeeApp.Router(`/debug/pprof`, &ProfController{})
BeeApp.Router(`/debug/pprof/:pp([\w]+)`, &ProfController{})
}
if SessionOn {
GlobalSessions, _ = session.NewManager(SessionProvider, SessionName, SessionGCMaxLifetime)