當前位置: 首頁>>代碼示例>>Golang>>正文


Golang revel.OnAppStart函數代碼示例

本文整理匯總了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)
}
開發者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


注:本文中的github.com/robfig/revel.OnAppStart函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。