mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 13:20:55 +00:00
rename AppConfigPath, AppConfigProvider to appConfigPath, appConfigProvider, make public to private
This commit is contained in:
parent
ccce566ba7
commit
31ef4ae507
4
admin.go
4
admin.go
@ -90,8 +90,8 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
|
||||
switch command {
|
||||
case "conf":
|
||||
m := make(map[string]interface{})
|
||||
m["AppConfigPath"] = AppConfigPath
|
||||
m["AppConfigProvider"] = AppConfigProvider
|
||||
m["AppConfigPath"] = appConfigPath
|
||||
m["AppConfigProvider"] = appConfigProvider
|
||||
m["BConfig.AppName"] = BConfig.AppName
|
||||
m["BConfig.RunMode"] = BConfig.RunMode
|
||||
m["BConfig.RouterCaseSensitive"] = BConfig.RouterCaseSensitive
|
||||
|
2
beego.go
2
beego.go
@ -85,7 +85,7 @@ func initBeforeHTTPRun() {
|
||||
// TestBeegoInit is for test package init
|
||||
func TestBeegoInit(ap string) {
|
||||
os.Setenv("BEEGO_RUNMODE", "test")
|
||||
AppConfigPath = filepath.Join(ap, "conf", "app.conf")
|
||||
appConfigPath = filepath.Join(ap, "conf", "app.conf")
|
||||
os.Chdir(ap)
|
||||
initBeforeHTTPRun()
|
||||
}
|
||||
|
30
config.go
30
config.go
@ -106,16 +106,16 @@ var (
|
||||
AppConfig *beegoAppConfig
|
||||
// AppPath is the absolute path to the app
|
||||
AppPath string
|
||||
// AppConfigPath is the path to the config files
|
||||
AppConfigPath string
|
||||
// AppConfigProvider is the provider for the config, default is ini
|
||||
AppConfigProvider = "ini"
|
||||
// TemplateCache stores template caching
|
||||
TemplateCache map[string]*template.Template
|
||||
// GlobalSessions is the instance for the session manager
|
||||
GlobalSessions *session.Manager
|
||||
|
||||
workPath string
|
||||
// appConfigPath is the path to the config files
|
||||
appConfigPath string
|
||||
// appConfigProvider is the provider for the config, default is ini
|
||||
appConfigProvider = "ini"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -187,18 +187,18 @@ func init() {
|
||||
},
|
||||
}
|
||||
|
||||
AppConfigPath = filepath.Join(AppPath, "conf", "app.conf")
|
||||
if !utils.FileExists(AppConfigPath) {
|
||||
appConfigPath = filepath.Join(AppPath, "conf", "app.conf")
|
||||
if !utils.FileExists(appConfigPath) {
|
||||
AppConfig = &beegoAppConfig{config.NewFakeConfig()}
|
||||
return
|
||||
}
|
||||
|
||||
parseConfig(AppConfigPath)
|
||||
parseConfig(appConfigPath)
|
||||
}
|
||||
|
||||
// now only support ini, next will support json.
|
||||
func parseConfig(appConfigPath string) (err error) {
|
||||
AppConfig, err = newAppConfig(AppConfigProvider, appConfigPath)
|
||||
AppConfig, err = newAppConfig(appConfigProvider, appConfigPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -312,7 +312,7 @@ func parseConfig(appConfigPath string) (err error) {
|
||||
}
|
||||
|
||||
// LoadAppConfig allow developer to apply a config file
|
||||
func LoadAppConfig(adapterName string, configPath string) error {
|
||||
func LoadAppConfig(adapterName, configPath string) error {
|
||||
absConfigPath, err := filepath.Abs(configPath)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -322,22 +322,22 @@ func LoadAppConfig(adapterName string, configPath string) error {
|
||||
return fmt.Errorf("the target config file: %s don't exist!", configPath)
|
||||
}
|
||||
|
||||
if absConfigPath == AppConfigPath {
|
||||
if absConfigPath == appConfigPath {
|
||||
return nil
|
||||
}
|
||||
|
||||
AppConfigPath = absConfigPath
|
||||
AppConfigProvider = adapterName
|
||||
appConfigPath = absConfigPath
|
||||
appConfigProvider = adapterName
|
||||
|
||||
return parseConfig(AppConfigPath)
|
||||
return parseConfig(appConfigPath)
|
||||
}
|
||||
|
||||
type beegoAppConfig struct {
|
||||
innerConfig config.Configer
|
||||
}
|
||||
|
||||
func newAppConfig(AppConfigProvider, AppConfigPath string) (*beegoAppConfig, error) {
|
||||
ac, err := config.NewConfig(AppConfigProvider, AppConfigPath)
|
||||
func newAppConfig(appConfigProvider, appConfigPath string) (*beegoAppConfig, error) {
|
||||
ac, err := config.NewConfig(appConfigProvider, appConfigPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user