Ejemplo n.º 1
0
func serverInit(pServer *sapi.Server) error {
	var err error
	dir := pServer.Conf.String("wgf.view.dir", pServer.Basedir()+"/view/")
	SetViewDir(dir)

	confAutoRefresh = pServer.Conf.Bool("wgf.view.autoRefresh", true)

	_, err = os.Stat(dir)
	if nil != err {
		pServer.Logger.Warning(err)
		return nil
	}

	err = filepath.Walk(
		confViewDir,
		func(path string, info os.FileInfo, err error) error {
			if !info.IsDir() {
				e := initTemplate(path)
				if nil != e {
					pServer.Logger.Warning("view_init_error " + e.Error() + " " + path)
					return e
				}
			}
			return nil
		},
	)

	if nil != err {
		pServer.Logger.Warning(err)
	}
	return err
}
Ejemplo n.º 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.Log(fmt.Sprintf("router error when addRule, %s=%s, errors: %s", key, val, err.Error()))
		}
	}
	return nil
}