本文整理汇总了Golang中github.com/robfig/revel.OnAppStart函数的典型用法代码示例。如果您正苦于以下问题:Golang OnAppStart函数的具体用法?Golang OnAppStart怎么用?Golang OnAppStart使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OnAppStart函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
}
示例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)
}
}
示例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.
}
}
示例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)
})
}
示例5: init
func init() {
revel.OnAppStart(func() {
uploadPath = fmt.Sprintf("%s/public/upload/", revel.BasePath)
})
revel.InterceptMethod((*Application).inject, revel.BEFORE)
}
示例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)
}
示例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
}
}
示例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.
}
}
示例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)
}
示例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.")
})
}
示例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)
})
}
示例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)
})
}
示例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)
}
})
}
示例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)
}
})
}
示例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")
}
}