コード例 #1
0
ファイル: init.go プロジェクト: ehrudxo/GoMap
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)
}
コード例 #2
0
ファイル: init.go プロジェクト: revolvingcow/grassfed
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)
}
コード例 #3
0
ファイル: init.go プロジェクト: wp132422/GOBOARD
func init() {
	revel.OnAppStart(InitDB)
	revel.InterceptMethod((*GorpController).Begin, revel.BEFORE)

	revel.InterceptMethod((*GorpController).Commit, revel.AFTER)
	revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY)
}
コード例 #4
0
ファイル: plugin.go プロジェクト: nashtsai/xormrevelmodule
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)
}
コード例 #5
0
ファイル: init.go プロジェクト: R510/revel
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)
}
コード例 #6
0
ファイル: init.go プロジェクト: netw0rm/reweb
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)
}
コード例 #7
0
ファイル: init.go プロジェクト: k0kubun/pr_viewer
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)
}
コード例 #8
0
ファイル: init.go プロジェクト: joho/firesize
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)
}
コード例 #9
0
ファイル: init.go プロジェクト: kcolls/revel-modz
// 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()
		}
	})

}
コード例 #10
0
ファイル: init.go プロジェクト: akaimo/iidaPro-2015-Server
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) // ログインの確認
}
コード例 #11
0
ファイル: init.go プロジェクト: kcolls/revel-modz
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 }

}
コード例 #12
0
ファイル: init.go プロジェクト: huntaub/list
func StartApp() {
	revel.INFO.Printf("Beginning Initialization Process...")

	// Load Database Connections
	revel.INFO.Printf("Connecting to Database...")
	session, err := mgo.Dial("mongodb://*****:*****@oceanic.mongohq.com: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")
}
コード例 #13
0
ファイル: init.go プロジェクト: bertzzie/obrolansubuh-backend
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, "")
	}
}
コード例 #14
0
ファイル: init.go プロジェクト: nashtsai/gorevel
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
	}
}
コード例 #15
0
ファイル: init.go プロジェクト: hackerlist/monty
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)
}
コード例 #16
0
ファイル: init.go プロジェクト: jango2015/baseapp
func init() {
	revel.OnAppStart(InitDB)
	revel.InterceptMethod((*GorpController).Begin, revel.BEFORE)
	revel.InterceptMethod(Account.AddAppName, revel.BEFORE)
	revel.InterceptMethod(Account.AddRenderMode, revel.BEFORE)
	revel.InterceptMethod(Account.AddUser, revel.BEFORE)
	revel.InterceptMethod((*GorpController).Commit, revel.AFTER)
	revel.InterceptMethod((*GorpController).Rollback, revel.FINALLY)
}
コード例 #17
0
ファイル: mongodb.go プロジェクト: dbenson24/revel-testing
func init() {
	revel.InterceptMethod((*MongoController).Open, revel.BEFORE)
	revel.InterceptMethod((*MongoController).Close, revel.AFTER)
	revel.InterceptMethod((*MongoController).Error, revel.PANIC)
}
コード例 #18
0
ファイル: nodes.go プロジェクト: huoshiqiu/mediom
func init() {
	revel.InterceptMethod((*Nodes).Before, revel.BEFORE)
}
コード例 #19
0
ファイル: init.go プロジェクト: nangong92t/go_src
func init() {
	// revel.OnAppStart(InitDb)
	revel.InterceptMethod((*AbstractController).Begin, revel.BEFORE)
	revel.InterceptMethod((*AbstractController).Commit, revel.AFTER)
	revel.InterceptMethod((*AbstractController).Rollback, revel.FINALLY)
}
コード例 #20
0
ファイル: users.go プロジェクト: codedogfish/mediom
func init() {
	revel.InterceptMethod((*Users).Before, revel.BEFORE)
	// revel.InterceptMethod((*Users).After, revel.AFTER)
}
コード例 #21
0
ファイル: controllers.go プロジェクト: thnguyn2/WebGPU
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()
	}
}
コード例 #22
0
ファイル: init.go プロジェクト: goors/revel-oauth2-restful
func init() {
	revel.InterceptMethod(App.Init, revel.BEFORE)
}
コード例 #23
0
ファイル: revmgo.go プロジェクト: MaxwellPayne/revmgo
func ControllerInit() {
	revel.InterceptMethod((*MongoController).Begin, revel.BEFORE)
	revel.InterceptMethod((*MongoController).End, revel.FINALLY)
}
コード例 #24
0
ファイル: init.go プロジェクト: jango2015/bloggo
func init() {
	revmgo.ControllerInit()
	revel.InterceptMethod((*Application).Setup, revel.BEFORE)
}
コード例 #25
0
ファイル: init.go プロジェクト: toxer/log4all
func init() {
	revel.InterceptMethod((*DbController).Begin, revel.BEFORE)
}
コード例 #26
0
ファイル: init.go プロジェクト: jango2015/OJ
func initIntercepter() {
	revel.InterceptMethod(authenticate, revel.BEFORE)
}
コード例 #27
0
ファイル: rmgo.go プロジェクト: oblank/revel-mgo
func init() {
	revel.OnAppStart(Init)
	revel.InterceptMethod((*MongoController).Begin, revel.BEFORE)
	revel.InterceptMethod((*MongoController).End, revel.FINALLY)
}
コード例 #28
0
ファイル: settings.go プロジェクト: codedogfish/mediom
func init() {
	revel.InterceptMethod((*Settings).Before, revel.BEFORE)
}
コード例 #29
0
ファイル: init.go プロジェクト: syphoxy/gosonic
func init() {
	r.OnAppStart(InitDB)
	r.InterceptMethod((*DbController).Begin, r.BEFORE)
	r.InterceptMethod((*DbController).Commit, r.AFTER)
	r.InterceptMethod((*DbController).Rollback, r.FINALLY)
}
コード例 #30
0
ファイル: init.go プロジェクト: creer/revel-contact-sample
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) // 異常時処理
}