Fix 4435: panic when controllers package not found
This commit is contained in:
parent
452d20a187
commit
53f01e50ce
@ -4,3 +4,4 @@
|
||||
- Using fixed name `commentRouter.go` as generated file name. [4385](https://github.com/beego/beego/pull/4385)
|
||||
- Fix 4383: ORM Adapter produces panic when using orm.RegisterModelWithPrefix. [4386](https://github.com/beego/beego/pull/4386)
|
||||
- Fix 4444: panic when 404 not found. [4446](https://github.com/beego/beego/pull/4446)
|
||||
- Fix 4435: fix panic when controller dir not found.
|
||||
@ -108,8 +108,11 @@ func registerAdmin() error {
|
||||
c := &adminController{
|
||||
servers: make([]*HttpServer, 0, 2),
|
||||
}
|
||||
|
||||
// copy config to avoid conflict
|
||||
adminCfg := *BConfig
|
||||
beeAdminApp = &adminApp{
|
||||
HttpServer: NewHttpServerWithCfg(BConfig),
|
||||
HttpServer: NewHttpServerWithCfg(&adminCfg),
|
||||
}
|
||||
// keep in mind that all data should be html escaped to avoid XSS attack
|
||||
beeAdminApp.Router("/", c, "get:AdminIndex")
|
||||
|
||||
@ -6,6 +6,8 @@ import (
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/coreos/etcd/pkg/fileutil"
|
||||
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/beego/v2/server/web/context"
|
||||
"github.com/beego/beego/v2/server/web/session"
|
||||
@ -98,7 +100,12 @@ func registerGzip() error {
|
||||
|
||||
func registerCommentRouter() error {
|
||||
if BConfig.RunMode == DEV {
|
||||
if err := parserPkg(filepath.Join(WorkPath, BConfig.WebConfig.CommentRouterPath)); err != nil {
|
||||
ctrlDir := filepath.Join(WorkPath, BConfig.WebConfig.CommentRouterPath)
|
||||
if !fileutil.Exist(ctrlDir) {
|
||||
logs.Warn("controller package not found, won't generate router: ", ctrlDir)
|
||||
return nil
|
||||
}
|
||||
if err := parserPkg(ctrlDir); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user