• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang revel.OnAppStart函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/robfig/revel.OnAppStart函数的典型用法代码示例。如果您正苦于以下问题:Golang OnAppStart函数的具体用法?Golang OnAppStart怎么用?Golang OnAppStart使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了OnAppStart函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: init

func init() {
	revel.OnAppStart(models.Init)
	revel.OnAppStart(GorpInit)
	revel.InterceptMethod((*GorpController).Begin, revel.BEFORE)
	revel.InterceptMethod((*GorpController).Commit, revel.AFTER)
	revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY)
}
开发者ID:Chandler,项目名称:goflesh,代码行数:7,代码来源:app.go


示例2: init

func init() {
	// Filters is the default set of global filters.
	revel.OnAppStart(revmgo.AppInit)
	revel.OnAppStart(AppInit)
	revel.Filters = []revel.Filter{
		revel.PanicFilter,             // Recover from panics and display an error page instead.
		revel.RouterFilter,            // Use the routing table to select the right Action
		revel.FilterConfiguringFilter, // A hook for adding or removing per-Action filters.
		revel.ParamsFilter,            // Parse parameters into Controller.Params.
		revel.SessionFilter,           // Restore and write the session cookie.
		revel.FlashFilter,             // Restore and write the flash cookie.
		revel.ValidationFilter,        // Restore kept validation errors and save new ones from cookie.
		revel.I18nFilter,              // Resolve the requested language
		revel.InterceptorFilter,       // Run interceptors around the action.
		revel.ActionInvoker,           // Invoke the action.
	}

	revel.TemplateFuncs["HighLight"] = func(src string, key string) string {
		res := ""
		if strings.Contains(src, key) {
			res = strings.Replace(src, key, "<em>"+key+"</em>", -1)
		}
		return res
	}

	revel.TemplateFuncs["join"] = func(a []string, sep string) string {
		return strings.Join(a, sep)
	}
}
开发者ID:heaven0sky,项目名称:yisoso,代码行数:29,代码来源:init.go


示例3: init

func init() {
	revel.OnAppStart(func() {
		// Fix don't run on weekends
		thumbnailServerUrl, _ := revel.Config.String("thumbnail_server")
		directory, _ := revel.Config.String("root_dir")
		revel.ERROR.Printf("The directory is %s", directory)
		jobs.Schedule("@midnight", photoJobs.GenerateThumbnails{Server: thumbnailServerUrl,
			Directory: directory,
			Duration:  10800})
	})

	// Filters is the default set of global filters.
	revel.Filters = []revel.Filter{
		revel.PanicFilter,             // Recover from panics and display an error page instead.
		revel.RouterFilter,            // Use the routing table to select the right Action
		revel.FilterConfiguringFilter, // A hook for adding or removing per-Action filters.
		revel.ParamsFilter,            // Parse parameters into Controller.Params.
		revel.SessionFilter,           // Restore and write the session cookie.
		revel.FlashFilter,             // Restore and write the flash cookie.
		revel.ValidationFilter,        // Restore kept validation errors and save new ones from cookie.
		revel.I18nFilter,              // Resolve the requested language
		revel.InterceptorFilter,       // Run interceptors around the action.
		revel.ActionInvoker,           // Invoke the action.
	}
}
开发者ID:paytonrules,项目名称:photolibrary,代码行数:25,代码来源:init.go


示例4: init

func init() {
	revel.OnAppStart(func() {
		// Set the default expiration time.
		defaultExpiration := time.Hour // The default for the default is one hour.
		if expireStr, found := revel.Config.String("cache.expires"); found {
			var err error
			if defaultExpiration, err = time.ParseDuration(expireStr); err != nil {
				panic("Could not parse default cache expiration duration " + expireStr + ": " + err.Error())
			}
		}

		// Use memcached?
		if revel.Config.BoolDefault("cache.memcached", false) {
			hosts := strings.Split(revel.Config.StringDefault("cache.hosts", ""), ",")
			if len(hosts) == 0 {
				panic("Memcache enabled but no memcached hosts specified!")
			}

			Instance = NewMemcachedCache(hosts, defaultExpiration)
			return
		}

		// By default, use the in-memory cache.
		Instance = NewInMemoryCache(defaultExpiration)
	})
}
开发者ID:adarshaj,项目名称:revel,代码行数:26,代码来源:init.go


示例5: init

func init() {
	revel.OnAppStart(func() {
		uploadPath = fmt.Sprintf("%s/public/upload/", revel.BasePath)
	})

	revel.InterceptMethod((*Application).inject, revel.BEFORE)
}
开发者ID:jsli,项目名称:gorevel,代码行数:7,代码来源:init.go


示例6: init

func init() {
	revel.OnAppStart(Init)
	revel.InterceptMethod((*GorpController).Begin, revel.BEFORE)
	//	revel.InterceptMethod(Application.AddUser, revel.BEFORE)
	//	revel.InterceptMethod(Hotels.checkUser, revel.BEFORE)
	revel.InterceptMethod((*GorpController).Commit, revel.AFTER)
	revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY)
}
开发者ID:pombredanne,项目名称:goqdb,代码行数:8,代码来源:init.go


示例7: init

func init() {
	revel.OnAppStart(Init)
	revel.InterceptMethod((*Application).checkUser, revel.BEFORE)

	revel.TemplateFuncs["eqis"] = func(i int64, s string) bool {
		return strconv.FormatInt(i, 10) == s
	}
}
开发者ID:zeuson,项目名称:gorevel,代码行数:8,代码来源:init.go


示例8: init

func init() {
	revel.OnAppStart(AppInit)
	revel.OnAppStart(revmgo.AppInit)

	// Filters is the default set of global filters.
	revel.Filters = []revel.Filter{
		revel.PanicFilter,             // Recover from panics and display an error page instead.
		revel.RouterFilter,            // Use the routing table to select the right Action
		revel.FilterConfiguringFilter, // A hook for adding or removing per-Action filters.
		revel.ParamsFilter,            // Parse parameters into Controller.Params.
		revel.SessionFilter,           // Restore and write the session cookie.
		revel.FlashFilter,             // Restore and write the flash cookie.
		revel.ValidationFilter,        // Restore kept validation errors and save new ones from cookie.
		revel.I18nFilter,              // Resolve the requested language
		revel.InterceptorFilter,       // Run interceptors around the action.
		revel.ActionInvoker,           // Invoke the action.
	}
}
开发者ID:argentum47,项目名称:Fio,代码行数:18,代码来源:init.go


示例9: init

func init() {
	revel.OnAppStart(Init)
	yield.DefaultLayout["html"] = "application.html"

	revel.InterceptMethod((*GorpController).Begin, revel.BEFORE)
	revel.InterceptMethod(Application.AddUser, revel.BEFORE)
	revel.InterceptMethod(Hotels.checkUser, revel.BEFORE)
	revel.InterceptMethod((*GorpController).Commit, revel.AFTER)
	revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY)
}
开发者ID:hura,项目名称:yield,代码行数:10,代码来源:init.go


示例10: init

func init() {
	MainCron = cron.New()
	revel.OnAppStart(func() {
		if size := revel.Config.IntDefault("jobs.pool", DEFAULT_JOB_POOL_SIZE); size > 0 {
			workPermits = make(chan struct{}, size)
		}
		selfConcurrent = revel.Config.BoolDefault("jobs.selfconcurrent", false)
		MainCron.Start()
		fmt.Println("Go to /@jobs to see job status.")
	})
}
开发者ID:huaguzi,项目名称:revel,代码行数:11,代码来源:plugin.go


示例11: init

func init() {
	revel.Filters = []revel.Filter{
		revel.RouterFilter,
		revel.ParamsFilter,
		revel.ActionInvoker,
	}
	revel.OnAppStart(func() {
		runtime.GOMAXPROCS(runtime.NumCPU())
		db.Init()
		qbs.ChangePoolSize(MaxConnectionCount)
	})
}
开发者ID:kazeburo,项目名称:FrameworkBenchmarks,代码行数:12,代码来源:app.go


示例12: init

func init() {
	revel.Filters = []revel.Filter{
		revel.RouterFilter,
		revel.ParamsFilter,
		revel.ActionInvoker,
	}
	revel.OnAppStart(func() {
		runtime.GOMAXPROCS(runtime.NumCPU())
		db.Init()
		db.Jet.SetMaxIdleConns(MaxConnectionCount)
	})
}
开发者ID:kazeburo,项目名称:FrameworkBenchmarks,代码行数:12,代码来源:app.go


示例13: init

func init() {
	revel.OnAppStart(func() {
		var err error
		runtime.GOMAXPROCS(runtime.NumCPU())
		db.DbPlugin{}.OnAppStart()
		db.Db.SetMaxIdleConns(MaxConnectionCount)
		if worldStatement, err = db.Db.Prepare(WorldSelect); err != nil {
			revel.ERROR.Fatalln(err)
		}
		if fortuneStatement, err = db.Db.Prepare(FortuneSelect); err != nil {
			revel.ERROR.Fatalln(err)
		}
	})
}
开发者ID:rismalrv,项目名称:FrameworkBenchmarks,代码行数:14,代码来源:app.go


示例14: init

func init() {

	revel.OnAppStart(func() {
		revel.WARN.Println("开始执行")

		//检测是否登陆
		revel.InterceptMethod(CheckLogin, revel.BEFORE)

		//多核运行
		np := runtime.NumCPU()
		if np >= 2 {
			runtime.GOMAXPROCS(np - 1)
		}
	})
}
开发者ID:jsli,项目名称:GoCMS,代码行数:15,代码来源:init.go


示例15: init

func init() {
	revel.OnAppStart(Init)

	revel.InterceptMethod((*Qbs).Begin, revel.BEFORE)
	revel.InterceptMethod((*Application).inject, revel.BEFORE)
	revel.InterceptMethod((*Qbs).End, revel.AFTER)

	//注册模板函数,
	//不等于
	revel.TemplateFuncs["notEq"] = func(a, b interface{}) bool { return a != b }

	revel.TemplateFuncs["dateFormat"] = func(t time.Time) string {
		return t.Format("2006-01-02")
	}
}
开发者ID:river-lee,项目名称:qishare,代码行数:15,代码来源:init.go


示例16: init

func init() {
	revel.OnAppStart(func() {
		var (
			found   bool
			spec    []string
			dialect qbs.Dialect
		)

		if Driver, found = revel.Config.String("db.driver"); !found {
			revel.ERROR.Fatal("No db.driver found.")
		}
		switch strings.ToLower(Driver) {
		case "mysql":
			dialect = qbs.NewMysql()
		case "postgres":
			dialect = qbs.NewPostgres()
		case "sqlite3":
			dialect = qbs.NewSqlite3()
		}

		// Start building the spec from available config options
		if User, found = revel.Config.String("db.user"); found {
			spec = append(spec, User)
			if Password, found = revel.Config.String("db.password"); found {
				spec = append(spec, fmt.Sprintf(":%v", Password))
			}
			spec = append(spec, "@")
		}
		if Protocol, found = revel.Config.String("db.protocol"); found {
			spec = append(spec, Protocol)
			if Address, found = revel.Config.String("db.address"); found {
				spec = append(spec, fmt.Sprintf("(%v)", Address))
			}
		}
		if DbName, found = revel.Config.String("db.dbname"); !found {
			revel.ERROR.Fatal("No db.dbname found.")
		}
		spec = append(spec, fmt.Sprintf("/%v", DbName))
		if Params, found = revel.Config.String("db.params"); found {
			spec = append(spec, fmt.Sprintf("?%v", Params))
		}

		qbs.Register(Driver, strings.Join(spec, ""), DbName, dialect)
		Db, err = qbs.GetQbs()
		defer Db.Close()
	})
}
开发者ID:robfig,项目名称:acvte,代码行数:47,代码来源:init.go


示例17: init

func init() {
	revel.OnAppStart(func() {
		// Set the default expiration time.
		defaultExpiration := time.Hour // The default for the default is one hour.
		if expireStr, found := revel.Config.String("cache.expires"); found {
			var err error
			if defaultExpiration, err = time.ParseDuration(expireStr); err != nil {
				panic("Could not parse default cache expiration duration " + expireStr + ": " + err.Error())
			}
		}

		// make sure you aren't trying to use both memcached and redis
		if revel.Config.BoolDefault("cache.memcached", false) && revel.Config.BoolDefault("cache.redis", false) {
			panic("You've configured both memcached and redis, please only include configuration for one cache!")
		}

		// Use memcached?
		if revel.Config.BoolDefault("cache.memcached", false) {
			hosts := strings.Split(revel.Config.StringDefault("cache.hosts", ""), ",")
			if len(hosts) == 0 {
				panic("Memcache enabled but no memcached hosts specified!")
			}

			Instance = NewMemcachedCache(hosts, defaultExpiration)
			return
		}

		// Use Redis (share same config as memcached)?
		if revel.Config.BoolDefault("cache.redis", false) {
			hosts := strings.Split(revel.Config.StringDefault("cache.hosts", ""), ",")
			if len(hosts) == 0 {
				panic("Redis enabled but no Redis hosts specified!")
			}
			if len(hosts) > 1 {
				panic("Redis currently only supports one host!")
			}
			password := revel.Config.StringDefault("cache.redis.password", "")
			Instance = NewRedisCache(hosts[0], password, defaultExpiration)
			return
		}

		// By default, use the in-memory cache.
		Instance = NewInMemoryCache(defaultExpiration)
	})
}
开发者ID:huaguzi,项目名称:revel,代码行数:45,代码来源:init.go


示例18: init

func init() {

	// Seed the random library
	rand.Seed(time.Now().UTC().UnixNano())

	revel.OnAppStart(Init)
	revel.InterceptMethod((*GorpController).Begin, revel.BEFORE)
	//revel.InterceptMethod(Application.AddUser, revel.BEFORE)
	revel.InterceptMethod(App.AddUser, revel.BEFORE)
	revel.InterceptMethod(App.logEntry, revel.BEFORE)
	//revel.InterceptMethod(Hotels.checkUser, revel.BEFORE)
	revel.InterceptMethod((*GorpController).Commit, revel.AFTER)
	revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY)

	revel.TemplateFuncs["countryOption"] = getCountryOptions
	revel.TemplateFuncs["keyOption"] = getKeyOptions
	revel.TemplateFuncs["keyUsageOption"] = getKeyUsageOptions
	revel.TemplateFuncs["extKeyUsageOption"] = getExtKeyUsageOptions
}
开发者ID:shaheemirza,项目名称:CAGo,代码行数:19,代码来源:init.go


示例19: init

func init() {
	// Filters is the default set of global filters.
	revel.Filters = []revel.Filter{
		revel.PanicFilter,             // Recover from panics and display an error page instead.
		revel.RouterFilter,            // Use the routing table to select the right Action
		revel.FilterConfiguringFilter, // A hook for adding or removing per-Action filters.
		revel.ParamsFilter,            // Parse parameters into Controller.Params.
		revel.SessionFilter,           // Restore and write the session cookie.
		revel.FlashFilter,             // Restore and write the flash cookie.
		revel.ValidationFilter,        // Restore kept validation errors and save new ones from cookie.
		revel.I18nFilter,              // Resolve the requested language
		revel.InterceptorFilter,       // Run interceptors around the action.
		revel.ActionInvoker,           // Invoke the action.
	}

	// date formatting
	revel.TemplateFuncs["formatDate"] = func(date time.Time) string { return date.Format("02 January 2006") }

	// load the database
	revel.OnAppStart(revmgo.AppInit)
}
开发者ID:netsharec,项目名称:ironzebra,代码行数:21,代码来源:init.go


示例20: init

func init() {
	revel.OnAppStart(func() {

		// Put PanicJsonFilter right after the panic filter
		// Or put it right before the ActionInvoker.
		var index int = -1
		for i, f := range revel.Filters {
			if revel.FilterEq(f, revel.PanicFilter) {
				index = i + 1
			} else if revel.FilterEq(f, revel.ActionInvoker) {
				index = i
			}
		}
		if index == -1 {
			return
		}
		revel.Filters = append(revel.Filters, PanicJsonFilter)
		copy(revel.Filters[index+1:], revel.Filters[index:])
		revel.Filters[index] = PanicJsonFilter
	})
}
开发者ID:shmifaats,项目名称:rvljson,代码行数:21,代码来源:panicfilter.go



注:本文中的github.com/robfig/revel.OnAppStart函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang revel.Unbind函数代码示例发布时间:2022-05-28
下一篇:
Golang revel.InterceptMethod函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap