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 }
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 = filepath.Walk( confViewDir, func(path string, info os.FileInfo, err error) error { if !info.IsDir() { return initTemplate(path) } return nil }, ) if nil != err { pServer.Log(err) } return err }