1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 18:30:56 +00:00

rename AppConfigPath, AppConfigProvider to appConfigPath, appConfigProvider, make public to private

This commit is contained in:
youngsterxyf 2016-01-27 16:43:01 +08:00
parent ccce566ba7
commit 31ef4ae507
3 changed files with 18 additions and 18 deletions

View File

@ -90,8 +90,8 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
switch command { switch command {
case "conf": case "conf":
m := make(map[string]interface{}) m := make(map[string]interface{})
m["AppConfigPath"] = AppConfigPath m["AppConfigPath"] = appConfigPath
m["AppConfigProvider"] = AppConfigProvider m["AppConfigProvider"] = appConfigProvider
m["BConfig.AppName"] = BConfig.AppName m["BConfig.AppName"] = BConfig.AppName
m["BConfig.RunMode"] = BConfig.RunMode m["BConfig.RunMode"] = BConfig.RunMode
m["BConfig.RouterCaseSensitive"] = BConfig.RouterCaseSensitive m["BConfig.RouterCaseSensitive"] = BConfig.RouterCaseSensitive

View File

@ -85,7 +85,7 @@ func initBeforeHTTPRun() {
// TestBeegoInit is for test package init // TestBeegoInit is for test package init
func TestBeegoInit(ap string) { func TestBeegoInit(ap string) {
os.Setenv("BEEGO_RUNMODE", "test") os.Setenv("BEEGO_RUNMODE", "test")
AppConfigPath = filepath.Join(ap, "conf", "app.conf") appConfigPath = filepath.Join(ap, "conf", "app.conf")
os.Chdir(ap) os.Chdir(ap)
initBeforeHTTPRun() initBeforeHTTPRun()
} }

View File

@ -106,16 +106,16 @@ var (
AppConfig *beegoAppConfig AppConfig *beegoAppConfig
// AppPath is the absolute path to the app // AppPath is the absolute path to the app
AppPath string 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 stores template caching
TemplateCache map[string]*template.Template TemplateCache map[string]*template.Template
// GlobalSessions is the instance for the session manager // GlobalSessions is the instance for the session manager
GlobalSessions *session.Manager GlobalSessions *session.Manager
workPath string 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() { func init() {
@ -187,18 +187,18 @@ func init() {
}, },
} }
AppConfigPath = filepath.Join(AppPath, "conf", "app.conf") appConfigPath = filepath.Join(AppPath, "conf", "app.conf")
if !utils.FileExists(AppConfigPath) { if !utils.FileExists(appConfigPath) {
AppConfig = &beegoAppConfig{config.NewFakeConfig()} AppConfig = &beegoAppConfig{config.NewFakeConfig()}
return return
} }
parseConfig(AppConfigPath) parseConfig(appConfigPath)
} }
// now only support ini, next will support json. // now only support ini, next will support json.
func parseConfig(appConfigPath string) (err error) { func parseConfig(appConfigPath string) (err error) {
AppConfig, err = newAppConfig(AppConfigProvider, appConfigPath) AppConfig, err = newAppConfig(appConfigProvider, appConfigPath)
if err != nil { if err != nil {
return err return err
} }
@ -312,7 +312,7 @@ func parseConfig(appConfigPath string) (err error) {
} }
// LoadAppConfig allow developer to apply a config file // 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) absConfigPath, err := filepath.Abs(configPath)
if err != nil { if err != nil {
return err 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) return fmt.Errorf("the target config file: %s don't exist!", configPath)
} }
if absConfigPath == AppConfigPath { if absConfigPath == appConfigPath {
return nil return nil
} }
AppConfigPath = absConfigPath appConfigPath = absConfigPath
AppConfigProvider = adapterName appConfigProvider = adapterName
return parseConfig(AppConfigPath) return parseConfig(appConfigPath)
} }
type beegoAppConfig struct { type beegoAppConfig struct {
innerConfig config.Configer innerConfig config.Configer
} }
func newAppConfig(AppConfigProvider, AppConfigPath string) (*beegoAppConfig, error) { func newAppConfig(appConfigProvider, appConfigPath string) (*beegoAppConfig, error) {
ac, err := config.NewConfig(AppConfigProvider, AppConfigPath) ac, err := config.NewConfig(appConfigProvider, appConfigPath)
if err != nil { if err != nil {
return nil, err return nil, err
} }