示例#1
0
文件: wgf.go 项目: hermanschaaf/wgf
func initConf() *conf.Conf {
	var confFile string
	var pConf *conf.Conf
	var err error

	pConf = conf.NewConf()
	confFile = *basedir + "/conf/" + *conffile
	err = pConf.ParseFile(confFile)
	if nil != err {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(-1)
	}
	return pConf
}
示例#2
0
func serverInit(pServer *sapi.Server) error {
	confDefaultAction = pServer.Conf.String("wgf.router.defaultAction", "index")
	confEnableRewrite = pServer.Conf.Bool("wgf.router.enableRewrite", true)

	confRouterFilePath = pServer.Conf.String("wgf.router.confFile", "router.ini")
	if confRouterFilePath[0] != '/' {
		confRouterFilePath = pServer.Confdir() + confRouterFilePath
	}

	confRouter = conf.NewConf()
	confRouter.ParseFile(confRouterFilePath)

	var err error
	for key, val := range confRouter.Data() {
		err = addRule(key, val)
		if nil != err {
			pServer.Logger.Warningf("router error when addRule, %s=%s, errors: %s", key, val, err.Error())
		}
	}
	return nil
}