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


Golang revel.InterceptMethod函數代碼示例

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


在下文中一共展示了InterceptMethod函數的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.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

示例2: 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

示例3: 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

示例4: 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

示例5: init

func init() {
	revel.OnAppStart(InitDB)
	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:R510,項目名稱:revel,代碼行數:8,代碼來源:init.go

示例6: init

func init() {
	revel.OnAppStart(InitDB)

	revel.InterceptMethod((*XOrmController).Begin, revel.BEFORE)
	revel.InterceptMethod((*XOrmTnController).Begin, revel.BEFORE)
	revel.InterceptMethod((*XOrmTnController).Commit, revel.AFTER)
	revel.InterceptMethod((*XOrmTnController).Rollback, revel.PANIC)
}
開發者ID:netw0rm,項目名稱:reweb,代碼行數:8,代碼來源:init.go

示例7: init

func init() {
	revel.OnAppStart(InitDB)
	revel.InterceptMethod((*GorpController).Begin, revel.BEFORE)
	revel.InterceptMethod(Application.authorize, revel.BEFORE)
	revel.InterceptMethod(Application.setLoginUrl, revel.BEFORE)
	revel.InterceptMethod((*GorpController).Commit, revel.AFTER)
	revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY)
}
開發者ID:k0kubun,項目名稱:pr_viewer,代碼行數:8,代碼來源:init.go

示例8: init

func init() {
	revel.OnAppStart(InitDB)
	revel.InterceptMethod((*GorpController).Begin, revel.BEFORE)
	revel.InterceptMethod(Application.SetAccount, revel.BEFORE)
	revel.InterceptMethod(Dashboard.checkAccount, revel.BEFORE)
	revel.InterceptMethod((*GorpController).Commit, revel.AFTER)
	revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY)
}
開發者ID:joho,項目名稱:firesize,代碼行數:8,代碼來源:init.go

示例9: 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)
		}
	})

	// DB related stuff
	// add interceptors
	revel.InterceptMethod((*ctrl.DbController).Begin, revel.BEFORE)
	revel.InterceptMethod(ctrl.App.RenderArgsFill, revel.BEFORE)
	revel.InterceptMethod(ctrl.User.CheckLoggedIn, revel.BEFORE)
	revel.InterceptMethod((*ctrl.DbController).Commit, revel.AFTER)
	revel.InterceptMethod((*ctrl.DbController).Rollback, revel.FINALLY)
	// revel.InterceptMethod((*ctrl.DbController).GetUserLogin, revel.BEFORE)

	revel.OnAppStart(func() {
		ctrl.InitDB()
		if revel.RunMode == "dev" {
			ctrl.SetupDevDB()
		}
		if revel.RunMode == "prod" {
			ctrl.SetupTables()
		}
	})

}
開發者ID:kcolls,項目名稱:revel-modz,代碼行數:59,代碼來源:init.go

示例10: init

func init() {
	revel.OnAppStart(InitDB)                                         // DBやテーブルの作成
	revel.InterceptMethod((*GorpController).Begin, revel.BEFORE)     // transaction開始
	revel.InterceptMethod((*GorpController).Commit, revel.AFTER)     // 変更反映
	revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY) // 異常時処理

	revel.InterceptMethod(App.AddUser, revel.BEFORE)      // ログインユーザーの追加
	revel.InterceptMethod(Events.checkUser, revel.BEFORE) // ログインの確認
}
開發者ID:akaimo,項目名稱:iidaPro-2015-Server,代碼行數:9,代碼來源:init.go

示例11: init

func init() {
	revel.OnAppStart(GorpInit)
	revel.InterceptMethod((*GorpController).Begin, revel.BEFORE)
	revel.InterceptMethod((*User).getUserLogin, revel.BEFORE)
	revel.InterceptMethod((*GorpController).Commit, revel.AFTER)
	revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY)

	revel.TemplateFuncs["eq"] = func(a, b interface{}) bool { return a == b }

}
開發者ID:kcolls,項目名稱:revel-modz,代碼行數:10,代碼來源:init.go

示例12: StartApp

func StartApp() {
	revel.INFO.Printf("Beginning Initialization Process...")

	// Load Database Connections
	revel.INFO.Printf("Connecting to Database...")
	session, err := mgo.Dial("mongodb://leath:[email protected]:10000/list")
	if err != nil {
		panic(err)
	}

	collection = session.DB("list").C("classes")
	users = session.DB("list").C("users")
	rand.Seed(time.Now().UnixNano())

	// Start Parsing Lou's List
	revel.INFO.Printf("Launching Parser...")
	jobs.Now(Parser{})
	jobs.Every(1*time.Hour, Parser{})

	// Regex to Recognize Classes
	revel.INFO.Printf("Compiling Regular Expressions...")
	classRegex = regexp.MustCompile(`([A-z]{1,4})\s?(\d{4})\s?(?::{((?:,?\s?\d{1,3})+)})?`)
	sectionRegex = regexp.MustCompile(`\d{1,3}`)

	/*	revel.INFO.Printf("Adding Template Functions...")
		CreateTemplateFunctions()*/

	// Interceptions
	revel.INFO.Printf("Starting Interceptors...")
	revel.InterceptMethod(App.Init, revel.BEFORE)

	revel.INFO.Printf("Initialization Complete")
}
開發者ID:huntaub,項目名稱:list,代碼行數:33,代碼來源:init.go

示例13: 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, "")
	}
}
開發者ID:bertzzie,項目名稱:obrolansubuh-backend,代碼行數:17,代碼來源:init.go

示例14: 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:nashtsai,項目名稱:gorevel,代碼行數:8,代碼來源:init.go

示例15: init

func init() {
	// Set up the database.
	revel.OnAppStart(InitDB)

	// Start running the probes.
	revel.OnAppStart(func() {
		jobs.Every(10*time.Second, ProbeJob{})
	})

	// Before a request, make sure the right API token is set.
	revel.InterceptMethod((*GorpController).CheckToken, revel.BEFORE)

	// Before a request, we want to start a transaction.
	revel.InterceptMethod((*GorpController).Begin, revel.BEFORE)

	//	revel.InterceptMethod(Application.AddUser, revel.BEFORE)
	//	revel.InterceptMethod(Hotels.checkUser, revel.BEFORE)

	// When a request is done, we want to commit the transaction.
	revel.InterceptMethod((*GorpController).Commit, revel.AFTER)
	revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY)
}
開發者ID:hackerlist,項目名稱:monty,代碼行數:22,代碼來源:init.go


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