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


Golang revel.OnAppStart函數代碼示例

本文整理匯總了Golang中github.com/revel/revel.OnAppStart函數的典型用法代碼示例。如果您正苦於以下問題:Golang OnAppStart函數的具體用法?Golang OnAppStart怎麽用?Golang OnAppStart使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了OnAppStart函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


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