mirror of
https://github.com/astaxie/beego.git
synced 2024-11-26 07:41:30 +00:00
Merge pull request #2724 from JessonChan/develop
AddAPPStartHook func modify
This commit is contained in:
commit
fe3a224a23
20
beego.go
20
beego.go
@ -40,9 +40,9 @@ var (
|
|||||||
|
|
||||||
// AddAPPStartHook is used to register the hookfunc
|
// AddAPPStartHook is used to register the hookfunc
|
||||||
// The hookfuncs will run in beego.Run()
|
// The hookfuncs will run in beego.Run()
|
||||||
// such as sessionInit, middlerware start, buildtemplate, admin start
|
// such as initiating session , starting middleware , building template, starting admin control and so on.
|
||||||
func AddAPPStartHook(hf hookfunc) {
|
func AddAPPStartHook(hf ...hookfunc) {
|
||||||
hooks = append(hooks, hf)
|
hooks = append(hooks, hf...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run beego application.
|
// Run beego application.
|
||||||
@ -69,12 +69,14 @@ func Run(params ...string) {
|
|||||||
|
|
||||||
func initBeforeHTTPRun() {
|
func initBeforeHTTPRun() {
|
||||||
//init hooks
|
//init hooks
|
||||||
AddAPPStartHook(registerMime)
|
AddAPPStartHook(
|
||||||
AddAPPStartHook(registerDefaultErrorHandler)
|
registerMime,
|
||||||
AddAPPStartHook(registerSession)
|
registerDefaultErrorHandler,
|
||||||
AddAPPStartHook(registerTemplate)
|
registerSession,
|
||||||
AddAPPStartHook(registerAdmin)
|
registerTemplate,
|
||||||
AddAPPStartHook(registerGzip)
|
registerAdmin,
|
||||||
|
registerGzip,
|
||||||
|
)
|
||||||
|
|
||||||
for _, hk := range hooks {
|
for _, hk := range hooks {
|
||||||
if err := hk(); err != nil {
|
if err := hk(); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user