mirror of
https://github.com/astaxie/beego.git
synced 2024-11-21 19:30:54 +00:00
Fix BUG
This commit is contained in:
parent
2473e69417
commit
e6a257f987
@ -46,23 +46,9 @@ var beeAdminApp *adminApp
|
||||
var FilterMonitorFunc func(string, string, time.Duration, string, int) bool
|
||||
|
||||
func init() {
|
||||
c := &adminController{
|
||||
servers: make([]*HttpServer, 0, 2),
|
||||
}
|
||||
beeAdminApp = &adminApp{
|
||||
HttpServer: NewHttpServerWithCfg(*BConfig),
|
||||
}
|
||||
// keep in mind that all data should be html escaped to avoid XSS attack
|
||||
beeAdminApp.Router("/", c, "get:AdminIndex")
|
||||
beeAdminApp.Router("/qps", c, "get:QpsIndex")
|
||||
beeAdminApp.Router("/prof", c, "get:ProfIndex")
|
||||
beeAdminApp.Router("/healthcheck", c, "get:Healthcheck")
|
||||
beeAdminApp.Router("/task", c, "get:TaskStatus")
|
||||
beeAdminApp.Router("/listconf", c, "get:ListConf")
|
||||
beeAdminApp.Router("/metrics", c, "get:PrometheusMetrics")
|
||||
|
||||
FilterMonitorFunc = func(string, string, time.Duration, string, int) bool { return true }
|
||||
|
||||
beeAdminApp.Run()
|
||||
}
|
||||
|
||||
func list(root string, p interface{}, m M) {
|
||||
@ -110,11 +96,28 @@ func (admin *adminApp) Run() {
|
||||
}
|
||||
|
||||
logs.Info("Admin server Running on %s", addr)
|
||||
|
||||
admin.HttpServer.Run(addr)
|
||||
}
|
||||
|
||||
func registerAdmin() error {
|
||||
if BConfig.Listen.EnableAdmin {
|
||||
|
||||
c := &adminController{
|
||||
servers: make([]*HttpServer, 0, 2),
|
||||
}
|
||||
beeAdminApp = &adminApp{
|
||||
HttpServer: NewHttpServerWithCfg(*BConfig),
|
||||
}
|
||||
// keep in mind that all data should be html escaped to avoid XSS attack
|
||||
beeAdminApp.Router("/", c, "get:AdminIndex")
|
||||
beeAdminApp.Router("/qps", c, "get:QpsIndex")
|
||||
beeAdminApp.Router("/prof", c, "get:ProfIndex")
|
||||
beeAdminApp.Router("/healthcheck", c, "get:Healthcheck")
|
||||
beeAdminApp.Router("/task", c, "get:TaskStatus")
|
||||
beeAdminApp.Router("/listconf", c, "get:ListConf")
|
||||
beeAdminApp.Router("/metrics", c, "get:PrometheusMetrics")
|
||||
|
||||
go beeAdminApp.Run()
|
||||
}
|
||||
return nil
|
||||
|
@ -41,7 +41,7 @@ type Config struct {
|
||||
RouterCaseSensitive bool
|
||||
ServerName string
|
||||
RecoverPanic bool
|
||||
RecoverFunc func(*context.Context)
|
||||
RecoverFunc func(*context.Context, *Config)
|
||||
CopyRequestBody bool
|
||||
EnableGzip bool
|
||||
MaxMemory int64
|
||||
@ -169,7 +169,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
func (cfg *Config) defaultRecoverPanic(ctx *context.Context) {
|
||||
func defaultRecoverPanic(ctx *context.Context, cfg *Config) {
|
||||
if err := recover(); err != nil {
|
||||
if err == ErrAbort {
|
||||
return
|
||||
@ -281,7 +281,7 @@ func newBConfig() *Config {
|
||||
},
|
||||
}
|
||||
|
||||
res.RecoverFunc = res.defaultRecoverPanic
|
||||
res.RecoverFunc = defaultRecoverPanic
|
||||
return res
|
||||
}
|
||||
|
||||
|
@ -155,6 +155,7 @@ func NewControllerRegisterWithCfg(cfg *Config) *ControllerRegister {
|
||||
return beecontext.NewContext()
|
||||
},
|
||||
},
|
||||
cfg: cfg,
|
||||
}
|
||||
res.chainRoot = newFilterRouter("/*", res.serveHttp, WithCaseSensitive(false))
|
||||
return res
|
||||
@ -678,7 +679,7 @@ func (p *ControllerRegister) serveHttp(ctx *beecontext.Context) {
|
||||
)
|
||||
|
||||
if p.cfg.RecoverFunc != nil {
|
||||
defer p.cfg.RecoverFunc(ctx)
|
||||
defer p.cfg.RecoverFunc(ctx, p.cfg)
|
||||
}
|
||||
|
||||
ctx.Output.EnableGzip = p.cfg.EnableGzip
|
||||
|
@ -266,10 +266,6 @@ func (app *HttpServer) Run(addr string, mws ...MiddleWare) {
|
||||
<-endRunning
|
||||
}
|
||||
|
||||
func (app *HttpServer) Start() {
|
||||
|
||||
}
|
||||
|
||||
// Router see HttpServer.Router
|
||||
func Router(rootpath string, c ControllerInterface, mappingMethods ...string) *HttpServer {
|
||||
return BeeApp.Router(rootpath, c, mappingMethods...)
|
||||
|
Loading…
Reference in New Issue
Block a user