优化
This commit is contained in:
@@ -198,7 +198,11 @@ func (r *initializationRepo) Initialize(ctx context.Context, input *biz.Database
|
||||
return err
|
||||
}
|
||||
}
|
||||
ignoredAPIs := defaultIgnoredAPIs()
|
||||
staticPath := "uploads/file"
|
||||
if admin := r.data.runtime.Admin(); admin != nil && admin.Local != nil && strings.Trim(admin.Local.PathPrefix, "/") != "" {
|
||||
staticPath = strings.Trim(admin.Local.PathPrefix, "/")
|
||||
}
|
||||
ignoredAPIs := defaultIgnoredAPIs(staticPath)
|
||||
for _, ignored := range ignoredAPIs {
|
||||
if err := tx.FirstOrCreate(&ignored, ignored).Error; err != nil {
|
||||
return err
|
||||
@@ -250,10 +254,12 @@ func (r *initializationRepo) Initialize(ctx context.Context, input *biz.Database
|
||||
return nil
|
||||
}
|
||||
|
||||
func defaultIgnoredAPIs() []ignoredAPIPO {
|
||||
func defaultIgnoredAPIs(staticPath string) []ignoredAPIPO {
|
||||
staticRoute := "/" + strings.Trim(staticPath, "/") + "/*filepath"
|
||||
return []ignoredAPIPO{
|
||||
{Method: "GET", Path: "/api/freshCasbin"}, {Method: "GET", Path: "/health"},
|
||||
{Method: "GET", Path: "/swagger/*any"},
|
||||
{Method: "GET", Path: staticRoute}, {Method: "HEAD", Path: staticRoute},
|
||||
{Method: "POST", Path: "/system/reloadSystem"}, {Method: "POST", Path: "/base/login"},
|
||||
{Method: "POST", Path: "/base/captcha"}, {Method: "POST", Path: "/init/initdb"},
|
||||
{Method: "POST", Path: "/init/checkdb"}, {Method: "GET", Path: "/info/getInfoDataSource"},
|
||||
|
||||
Reference in New Issue
Block a user