Fix 4435: panic when controllers package not found
This commit is contained in:
parent
452d20a187
commit
53f01e50ce
@ -3,4 +3,5 @@
|
|||||||
- Fix `unknown escape sequence` in generated code. [4385](https://github.com/beego/beego/pull/4385)
|
- Fix `unknown escape sequence` in generated code. [4385](https://github.com/beego/beego/pull/4385)
|
||||||
- Using fixed name `commentRouter.go` as generated file name. [4385](https://github.com/beego/beego/pull/4385)
|
- 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 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 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{
|
c := &adminController{
|
||||||
servers: make([]*HttpServer, 0, 2),
|
servers: make([]*HttpServer, 0, 2),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// copy config to avoid conflict
|
||||||
|
adminCfg := *BConfig
|
||||||
beeAdminApp = &adminApp{
|
beeAdminApp = &adminApp{
|
||||||
HttpServer: NewHttpServerWithCfg(BConfig),
|
HttpServer: NewHttpServerWithCfg(&adminCfg),
|
||||||
}
|
}
|
||||||
// keep in mind that all data should be html escaped to avoid XSS attack
|
// keep in mind that all data should be html escaped to avoid XSS attack
|
||||||
beeAdminApp.Router("/", c, "get:AdminIndex")
|
beeAdminApp.Router("/", c, "get:AdminIndex")
|
||||||
|
|||||||
@ -6,6 +6,8 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/coreos/etcd/pkg/fileutil"
|
||||||
|
|
||||||
"github.com/beego/beego/v2/core/logs"
|
"github.com/beego/beego/v2/core/logs"
|
||||||
"github.com/beego/beego/v2/server/web/context"
|
"github.com/beego/beego/v2/server/web/context"
|
||||||
"github.com/beego/beego/v2/server/web/session"
|
"github.com/beego/beego/v2/server/web/session"
|
||||||
@ -98,7 +100,12 @@ func registerGzip() error {
|
|||||||
|
|
||||||
func registerCommentRouter() error {
|
func registerCommentRouter() error {
|
||||||
if BConfig.RunMode == DEV {
|
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
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user