本文整理匯總了Golang中github.com/revel/revel.InterceptFunc函數的典型用法代碼示例。如果您正苦於以下問題:Golang InterceptFunc函數的具體用法?Golang InterceptFunc怎麽用?Golang InterceptFunc使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了InterceptFunc函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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)
}
示例2: 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)
// 注冊模板裏的字符串相加函數
revel.TemplateFuncs["sp2bk"] = func(a string) string {
return strings.Replace(a, " ", " ", -1)
}
// 對訪問者身份進行驗證
revel.InterceptFunc(checkRole, revel.BEFORE, &controllers.Admin{})
revel.InterceptFunc(checkRole, revel.BEFORE, &controllers.Picture{})
}
示例3: init
func init() {
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &MemberIndex{})
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &MemberUser{})
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &MemberBlog{})
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &MemberGroup{})
revel.OnAppStart(func() {
})
}
示例4: init
func init() {
revel.OnAppStart(InitDB)
revel.InterceptFunc(checkUser, revel.BEFORE, &Post{})
revel.InterceptFunc(checkUser, revel.BEFORE, &Profile{})
revel.InterceptFunc(checkUser, revel.BEFORE, &Asset{})
revel.InterceptFunc(adminOnly, revel.BEFORE, &Contributor{})
revel.InterceptFunc(adminOnly, revel.BEFORE, &SiteInfo{})
//revel.InterceptFunc(adminOnly, revel.BEFORE, &Category{})
revel.InterceptMethod((*GormController).Begin, revel.BEFORE)
revel.InterceptMethod((*GormController).Commit, revel.AFTER)
revel.InterceptMethod((*GormController).RollBack, revel.FINALLY)
revel.TemplateFuncs["config"] = func(key string) string {
return revel.Config.StringDefault(key, "")
}
}
示例5: 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")
})
}
示例6: init
func init() {
revel.InterceptFunc(CheckUserAuth, revel.BEFORE, revel.ALL_CONTROLLERS)
revel.OnAppStart(func() {
ServersMap, ServersLastError = models.LoadServers()
if ServersLastError != nil {
revel.ERROR.Print(ServersLastError)
}
})
}
示例7: init
func init() {
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &Admin{})
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &AdminSetting{})
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &AdminUser{})
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &AdminBlog{})
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &AdminEmail{})
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &AdminUpgrade{})
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &AdminData{})
}
示例8: 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, &Album{})
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &File{})
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &Attach{})
// revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &Blog{})
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &NoteContentHistory{})
revel.OnAppStart(func() {
// 博客初始化模板
blog.Init()
})
}
示例9: init
func init() {
revel.OnAppStart(Bootstrap)
//檢測是否登陸
revel.InterceptFunc(CheckLogin, revel.BEFORE, revel.ALL_CONTROLLERS)
}
示例10: init
func init() {
revel.InterceptFunc(CheckLogin, revel.BEFORE, &Cmds{})
}
示例11: InitControllers
func InitControllers() {
revel.InterceptMethod(CheckCourseraMode, revel.BEFORE)
revel.InterceptMethod(PublicApplication.AddUser, revel.BEFORE)
revel.InterceptMethod(CheckWorker, revel.BEFORE)
revel.InterceptFunc(CheckUser, revel.BEFORE, &SecuredApplication{})
if CourseraMode {
revel.InterceptFunc(CheckUser, revel.BEFORE, &CourseraApplication{})
}
revel.TemplateFuncs["rfc3339"] = func(t time.Time) string {
return t.Format(time.RFC3339)
}
revel.TemplateFuncs["lower"] = func(s string) string {
return strings.ToLower(s)
}
revel.TemplateFuncs["plus"] = func(x int, y int) int {
return x + y
}
revel.TemplateFuncs["shorten"] = func(s string) string {
if len(s) > 60 {
bs := []byte(s)
return string(bs[:60]) + "..."
} else {
return s
}
}
revel.TemplateFuncs["percentageToInt"] = func(f float32) int {
return int(f * 100)
}
revel.TemplateFuncs["splitComma"] = func(str string) []string {
return strings.Split(str, ",")
}
revel.TemplateFuncs["positiveQ"] = func(i int) bool {
return i > 0
}
revel.TemplateFuncs["notEmpty"] = func(xs interface{}) bool {
vxs := reflect.ValueOf(xs)
return vxs.Len() > 0
}
revel.TemplateFuncs["loggerClass"] = func(s string) (class string) {
switch s {
case "Fatal":
case "Error":
class = "danger"
case "Warn":
class = "warning"
case "Info":
case "Debug":
class = "active"
default:
class = ""
}
return
}
revel.TemplateFuncs["milliSeconds"] = func(t int64) float64 {
return float64(t) / 1000000.0
}
MPFileDirectory = filepath.Join(revel.BasePath, "mp")
createBigCodeDatabaseMutex = &sync.Mutex{}
if CourseraMode {
InitCourseraController()
}
if IsMaster {
InitAdminController()
}
}
示例12: init
func init() {
revel.InterceptFunc(checkDataTypeParam, revel.BEFORE, &Synchronization{})
}
示例13: init
func init() {
revel.InterceptFunc(defaultRenderArgs, revel.BEFORE, &App{})
}
示例14: init
func init() {
revel.InterceptFunc(setuser, revel.BEFORE, &App{})
}
示例15: init
func init() {
revel.InterceptFunc(CheckLoginAdmin, revel.BEFORE, &Users{})
}