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

Remove dependency of third party lib

This commit is contained in:
Bill Davis 2014-10-09 09:17:10 -04:00
parent a06e0f27ad
commit a27f5c0dc0

View File

@ -26,7 +26,6 @@ import (
"github.com/astaxie/beego/logs" "github.com/astaxie/beego/logs"
"github.com/astaxie/beego/session" "github.com/astaxie/beego/session"
"github.com/astaxie/beego/utils" "github.com/astaxie/beego/utils"
"github.com/kelseyhightower/envconfig"
) )
var ( var (
@ -84,14 +83,9 @@ var (
RouterCaseSensitive bool // router case sensitive default is true RouterCaseSensitive bool // router case sensitive default is true
) )
type ( type beegoAppConfig struct {
beegoAppConfig struct {
innerConfig config.ConfigContainer innerConfig config.ConfigContainer
} }
beegoEnvConfig struct {
RunMode string
}
)
func newAppConfig(AppConfigProvider, AppConfigPath string) *beegoAppConfig { func newAppConfig(AppConfigProvider, AppConfigPath string) *beegoAppConfig {
ac, err := config.NewConfig(AppConfigProvider, AppConfigPath) ac, err := config.NewConfig(AppConfigProvider, AppConfigPath)
@ -294,15 +288,10 @@ func init() {
func ParseConfig() (err error) { func ParseConfig() (err error) {
AppConfig = newAppConfig(AppConfigProvider, AppConfigPath) AppConfig = newAppConfig(AppConfigProvider, AppConfigPath)
var ec beegoEnvConfig envRunMode := os.Getenv("BEEGO_RUNMODE")
err = envconfig.Process("beego", &ec)
if err != nil {
return err
}
// set the runmode first // set the runmode first
if ec.RunMode != "" { if envRunMode != "" {
RunMode = ec.RunMode RunMode = envRunMode
} else if runmode := AppConfig.String("RunMode"); runmode != "" { } else if runmode := AppConfig.String("RunMode"); runmode != "" {
RunMode = runmode RunMode = runmode
} }