本文整理汇总了Golang中github.com/revel/revel.OnAppStart函数的典型用法代码示例。如果您正苦于以下问题:Golang OnAppStart函数的具体用法?Golang OnAppStart怎么用?Golang OnAppStart使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OnAppStart函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: init
func init() {
// config
revel.OnAppStart(LoadConfig)
// gorp
revel.OnAppStart(InitDB)
// service account
revel.InterceptMethod((*AlphaWingController).InitGoogleService, revel.BEFORE)
// auth
revel.InterceptMethod((*AlphaWingController).InitOAuthConfig, revel.BEFORE)
revel.InterceptMethod((*AlphaWingController).SetLoginInfo, revel.BEFORE)
revel.InterceptMethod((*AuthController).CheckLogin, revel.BEFORE)
// validate app
revel.InterceptMethod((*AppControllerWithValidation).CheckNotFound, revel.BEFORE)
revel.InterceptMethod((*AppControllerWithValidation).CheckForbidden, revel.BEFORE)
// validate bundle
revel.InterceptMethod((*BundleControllerWithValidation).CheckNotFound, revel.BEFORE)
revel.InterceptMethod((*BundleControllerWithValidation).CheckForbidden, revel.BEFORE)
revel.InterceptMethod((*LimitedTimeController).CheckNotFound, revel.BEFORE)
// validate limited time token
revel.InterceptMethod((*LimitedTimeController).CheckValidLimitedTimeToken, revel.BEFORE)
// document
revel.OnAppStart(GenerateApiDocument)
// args
revel.InterceptMethod((*AlphaWingController).InitRenderArgs, revel.AFTER)
}
开发者ID:kayac,项目名称:alphawing,代码行数:33,代码来源:init.go
示例2: init
// in your app initialization..
func init() {
revel.TemplateFuncs["appendjs"] = func(renderArgs map[string]interface{}, key string, value interface{}) template.HTML {
s := value.(string)
js_code := template.JS(s)
if renderArgs[key] == nil {
renderArgs[key] = []interface{}{js_code}
} else {
renderArgs[key] = append(renderArgs[key].([]interface{}), js_code)
}
return template.HTML("")
}
// 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.
csrf.CSRFFilter, // CSRF prevention.
revel.ValidationFilter, // Restore kept validation errors and save new ones from cookie.
revel.I18nFilter, // Resolve the requested language
HeaderFilter, // Add some security based headers
revel.InterceptorFilter, // Run interceptors around the action.
revel.ActionInvoker, // Invoke the action.
}
revel.OnAppStart(func() {
appPath := revel.BasePath
for _, AC := range compilers {
path := filepath.Join(appPath, AC.Path)
revel.INFO.Printf("Listening: %q\n", path)
revel.MainWatcher.Listen(AC, path)
}
})
// add interceptors
revel.InterceptMethod((*ctrl.DbController).Begin, revel.BEFORE)
revel.InterceptMethod(ctrl.App.RenderArgsFill, revel.BEFORE)
revel.InterceptMethod(ctrl.App.RecordPageRequest, revel.BEFORE)
revel.InterceptMethod(ctrl.User.CheckLoggedIn, revel.BEFORE)
revel.InterceptMethod(ctrl.Admin.CheckLoggedIn, revel.BEFORE)
revel.InterceptMethod((*ctrl.DbController).Commit, revel.AFTER)
revel.InterceptMethod((*ctrl.DbController).Rollback, revel.FINALLY)
revel.OnAppStart(func() {
ctrl.InitDB()
if revel.RunMode == "dev" {
ctrl.SetupDevDB()
}
if revel.RunMode == "prod" {
ctrl.SetupTables()
}
})
}
开发者ID:jwmiller19,项目名称:revel-modz,代码行数:59,代码来源:init.go
示例3: init
func init() {
// interceptor
// revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &Index{}) // Index.Note自己校验
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &Notebook{})
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &Note{})
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &Share{})
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &User{})
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &File{})
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &Blog{})
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &NoteContentHistory{})
// service
userService = &service.UserService{}
noteService = &service.NoteService{}
trashService = &service.TrashService{}
notebookService = &service.NotebookService{}
noteContentHistoryService = &service.NoteContentHistoryService{}
authService = &service.AuthService{}
shareService = &service.ShareService{}
blogService = &service.BlogService{}
tagService = &service.TagService{}
pwdService = &service.PwdService{}
tokenService = &service.TokenService{}
suggestionService = &service.SuggestionService{}
revel.OnAppStart(func() {
leanoteUserId, _ = revel.Config.String("adminUsername")
siteUrl, _ = revel.Config.String("site.url")
openRegister, _ = revel.Config.Bool("register.open")
})
}
开发者ID:hello-kukoo,项目名称:leanote,代码行数:32,代码来源:init.go
示例4: init
func init() {
revel.OnAppStart(func() {
/*
不用配置的, 因为最终通过命令可以改, 而且有的使用nginx代理
port = strconv.Itoa(revel.HttpPort)
if port != "80" {
port = ":" + port
} else {
port = "";
}
*/
siteUrl, _ := revel.Config.String("site.url") // 已包含:9000, http, 去掉成 leanote.com
if strings.HasPrefix(siteUrl, "http://") {
defaultDomain = siteUrl[len("http://"):]
} else if strings.HasPrefix(siteUrl, "https://") {
defaultDomain = siteUrl[len("https://"):]
schema = "https://"
}
// port localhost:9000
ports := strings.Split(defaultDomain, ":")
if len(ports) == 2 {
port = ports[1]
}
if port == "80" {
port = ""
} else {
port = ":" + port
}
})
}
开发者ID:JacobXie,项目名称:leanote-daocloud,代码行数:32,代码来源:ConfigService.go
示例5: init
func init() {
revel.Filters = []revel.Filter{
revel.RouterFilter,
revel.ParamsFilter,
revel.ActionInvoker,
}
revel.OnAppStart(func() {
var err error
db.Init()
db.Db.SetMaxIdleConns(MaxConnectionCount)
dbm.InitJet()
dbm.Jet.SetMaxIdleConns(MaxConnectionCount)
dbm.InitQbs(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)
}
if updateStatement, err = db.Db.Prepare(WorldUpdate); err != nil {
revel.ERROR.Fatalln(err)
}
})
}
开发者ID:nathana1,项目名称:FrameworkBenchmarks,代码行数:25,代码来源:app.go
示例6: init
func init() {
revel.OnAppStart(InitDB)
revel.InterceptMethod((*GorpController).Begin, revel.BEFORE)
revel.InterceptMethod((*GorpController).Commit, revel.AFTER)
revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY)
}
开发者ID:wp132422,项目名称:GOBOARD,代码行数:7,代码来源:init.go
示例7: 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
HeaderFilter, // Add some security based headers
revel.InterceptorFilter, // Run interceptors around the action.
revel.CompressFilter, // Compress the result.
revel.ActionInvoker, // Invoke the action.
}
// register startup functions with OnAppStart
// Can also be called per init file in each package for package specific init function
// ( order dependent )
// revel.OnAppStart(InitDB)
// revel.OnAppStart(FillCache)
revel.OnAppStart(func() {
var found bool
Driver, found = revel.Config.String("db.driver")
if !found {
panic("db.driver is not defined in the config section.")
}
fmt.Println("Using db.driver value from config: %s", Driver)
})
}
开发者ID:memikequinn,项目名称:lfs-server-revel,代码行数:32,代码来源:init.go
示例8: init
func init() {
revel.OnAppStart(func() {
go common.UnzipSwaggerAssets()
// build IndexArgs for rendering index template
// collect all of the swagger-endpoints then build the spec
routes := make([]*revel.Route, 0)
for _, route := range revel.MainRouter.Routes {
if strings.ToLower(route.Action) == "swaggify.spec" {
routes = append(routes, route)
}
}
for _, route := range routes {
// TODO test what cases cause bounds panic
// Don't duplicate building API specs
if _, exists := APIs[route.FixedParams[0]]; exists {
continue
}
APIs[route.FixedParams[0]] = newSpec(route.FixedParams[0])
fmt.Println(APIs[route.FixedParams[0]])
}
})
}
开发者ID:waiteb3,项目名称:revel-swagger,代码行数:25,代码来源:swaggify.go
示例9: 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.I18nFilter, // Resolve the requested language
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.
csrf.CSRFFilter,
revel.FlashFilter, // Restore and write the flash cookie.
revel.ValidationFilter, // Restore kept validation errors and save new ones from cookie.
HeaderFilter, // Add xnsome security based headers
revel.InterceptorFilter, // Run interceptors around the action.
revel.CompressFilter, // Compress the result.
revel.ActionInvoker, // Invoke the action.
}
revel.OnAppStart(models.InitDB)
revel.InterceptFunc(setNickname, revel.BEFORE, &pages.ShopPage{})
revel.InterceptFunc(setNickname, revel.BEFORE, &pages.Authentication{})
revel.InterceptFunc(setNickname, revel.BEFORE, &pages.Admin{})
revel.InterceptFunc(redirectAuthenticationPageForAdmin, revel.BEFORE, &pages.Admin{})
// register startup functions with OnAppStart
// ( order dependent )
// revel.OnAppStart(InitDB)
// revel.OnAppStart(FillCache)
}
开发者ID:randyumi,项目名称:kuchikommi,代码行数:28,代码来源:init.go
示例10: init
func init() {
revel.InterceptMethod((*XormController).Attach, revel.BEFORE)
revel.InterceptMethod((*XormController).Commit, revel.AFTER)
revel.InterceptMethod((*XormController).Detach, revel.FINALLY)
revel.InterceptMethod((*XormSessionController).Attach, revel.BEFORE)
revel.OnAppStart(Init)
}
开发者ID:nashtsai,项目名称:xormrevelmodule,代码行数:7,代码来源:plugin.go
示例11: init
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
revel.TemplateFuncs["formatTime"] = func(t time.Time) template.HTML {
return template.HTML(t.Format(storage.TimePattern))
}
revel.TemplateFuncs["join"] = func(ss []string) template.HTML {
return template.HTML(strings.Join(ss, " "))
}
revel.TemplateFuncs["highlight"] = func(search string, input template.HTML) template.HTML {
inputS := string(input)
index := strings.Index(inputS, search)
if index == -1 {
return input
}
r := inputS[:index] + "<span class=highlight>" + search + "</span>" +
inputS[index+len(search):]
return template.HTML(r)
}
// forbid sequent handlers for go playground
playFilter := func(c *revel.Controller, fc []revel.Filter) {
c.Result = PlayResult{}
return
}
revel.FilterAction(Application.Play).
Insert(playFilter, revel.BEFORE, revel.ParamsFilter)
//register posts plugin
revel.OnAppStart(onStart)
}
开发者ID:tw4452852,项目名称:totorow,代码行数:29,代码来源:init.go
示例12: init
// in your app initialization..
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.
csrf.CSRFFilter, // CSRF prevention.
revel.ValidationFilter, // Restore kept validation errors and save new ones from cookie.
revel.I18nFilter, // Resolve the requested language
HeaderFilter, // Add some security based headers
revel.InterceptorFilter, // Run interceptors around the action.
revel.ActionInvoker, // Invoke the action.
}
revel.OnAppStart(func() {
appPath := revel.BasePath
for _, AC := range compilers {
path := filepath.Join(appPath, AC.Path)
revel.INFO.Printf("Listening: %q\n", path)
revel.MainWatcher.Listen(AC, path)
}
})
}
开发者ID:kcolls,项目名称:revel-modz,代码行数:28,代码来源:init.go
示例13: 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
HeaderFilter, // Add some security based headers
revel.InterceptorFilter, // Run interceptors around the action.
revel.CompressFilter, // Compress the result.
revel.ActionInvoker, // Invoke the action.
}
var card models.Card
revel.TypeBinders[reflect.TypeOf(card)] = binders.CardBinder
// register startup functions with OnAppStart
// ( order dependent )
revel.OnAppStart(database.InitDB)
// revel.OnAppStart(FillCache)
}
开发者ID:caneroj1,项目名称:cardsAPI,代码行数:25,代码来源:init.go
示例14: 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
HeaderFilter, // Add some security based headers
revel.InterceptorFilter, // Run interceptors around the action.
revel.CompressFilter, // Compress the result.
ActionInvoker, // Invoke the action.
}
// revel.TimeFormats = append(revel.TimeFormats, "2006/01/01")
// ( order dependent )
// revel.OnAppStart(InitDB)
// revel.OnAppStart(FillCache)
revel.OnAppStart(func() {
models.InitDB()
core.Init()
})
}
开发者ID:11101171,项目名称:whale,代码行数:25,代码来源:init.go
示例15: init
func init() {
revel.OnAppStart(func() {
assetsFixedParams = map[string][]string{
"prefix": []string{common.SwaggerAssetsDir},
}
})
}
开发者ID:waiteb3,项目名称:revel-swagger,代码行数:7,代码来源:swaggify.go
示例16: init
func init() {
revel.OnAppStart(Initialize)
revel.InterceptMethod((*DatabaseController).Begin, revel.BEFORE)
//revel.InterceptMethod((*Profile).Index, revel.BEFORE)
revel.InterceptMethod((*DatabaseController).Commit, revel.AFTER)
revel.InterceptMethod((*DatabaseController).Rollback, revel.FINALLY)
}
开发者ID:revolvingcow,项目名称:grassfed,代码行数:7,代码来源:init.go
示例17: 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
HeaderFilter, // Add some security based headers
revel.InterceptorFilter, // Run interceptors around the action.
revel.CompressFilter, // Compress the result.
revel.ActionInvoker, // Invoke the action.
}
// register startup functions with OnAppStart
// ( order dependent )
revel.OnAppStart(controllers.InitDB)
revel.InterceptMethod((*controllers.GormController).Begin, revel.BEFORE)
revel.InterceptMethod((*controllers.GormController).Commit, revel.AFTER)
revel.InterceptMethod((*controllers.GormController).Rollback, revel.FINALLY)
// revel.OnAppStart(FillCache)
}
开发者ID:ehrudxo,项目名称:GoMap,代码行数:25,代码来源:init.go
示例18: init
// HeaderFilter initialize Revel App
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
HeaderFilter, // Add some security based headers
revel.InterceptorFilter, // Run interceptors around the action.
revel.CompressFilter, // Compress the result.
revel.ActionInvoker, // Invoke the action.
}
// register startup functions with OnAppStart
// ( order dependent )
revel.OnAppStart(func() {
dbm := InitDB()
dbm.AutoMigrate(&usermodules.User{}, &usermodules.Profile{}, &models.SpendingType{}, &models.Spending{})
})
// revel.OnAppStart(FillCache)
}
开发者ID:BugisDev,项目名称:SpendingTracker,代码行数:26,代码来源: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
HeaderFilter, // Add some security based headers
revel.InterceptorFilter, // Run interceptors around the action.
revel.CompressFilter, // Compress the result.
revel.ActionInvoker, // Invoke the action.
}
// register startup functions with OnAppStart
// ( order dependent )
// revel.OnAppStart(InitDB)
// revel.OnAppStart(FillCache)
// Create a link back to node-webkit using the environment variable
// populated by golang-nw's node-webkit code
revel.OnAppStart(func() { open.Run("http://localhost:9000") })
}
开发者ID:browning,项目名称:gospider,代码行数:26,代码来源:init.go
示例20: init
func init() {
revel.OnAppStart(func() {
// set security key to app.secret
sec, found := revel.Config.String("app.secret")
if !found {
revel.ERROR.Fatal("No app.secret setting was found in app.conf.")
}
SecurityKey = sec
// setup providers allowed in app.config's auth.providersallowed setting
configItm, found := revel.Config.String("auth.providersallowed")
if found {
revel.INFO.Printf("Setting up the following providers: %s", configItm)
configResults := strings.Split(configItm, ",")
for idx := 0; idx < len(configResults); idx++ {
providerItm := strings.Trim(strings.ToLower(configResults[idx]), " ")
// set the AuthProvider for each type requested
switch providerItm {
case "facebook":
AllowedProviderGenerators["facebook"] = NewFacebookAuthProvider
case "google":
AllowedProviderGenerators["google"] = NewGoogleAuthProvider
case "linkedin":
AllowedProviderGenerators["linkedin"] = NewLinkedinAuthProvider
case "twitter":
AllowedProviderGenerators["twitter"] = NewTwitterAuthProvider
case "github":
AllowedProviderGenerators["github"] = NewGithubAuthProvider
default:
revel.WARN.Printf("Provider <%s> is not known. Skipped.", providerItm)
}
// pull AuthConfig settings from app.conf and validate it
ac, err := generateAuthConfigFromAppConfig(providerItm)
if err != nil {
revel.ERROR.Fatal(err)
} else {
validator := AuthConfigValidator.Validate(ac)
if validator.HasErrors() {
revel.WARN.Printf("Configuration data for %s does not validate. Added anyways, but please confirm settings.", providerItm)
} else {
revel.INFO.Printf("Configured %s for authentication.", providerItm)
}
AppAuthConfigs[providerItm] = ac
}
}
} else {
revel.ERROR.Fatal("No auth.providersallowed setting was found in app.conf.")
}
})
}
开发者ID:golightspeed,项目名称:bouncer,代码行数:59,代码来源:init.go
注:本文中的github.com/revel/revel.OnAppStart函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论