Beispiel #1
0
func init() {
	// Template delimiters
	delims := strings.Fields(config.GetView().Template.Delimiters)
	foundation.Template.Delims.Left, foundation.Template.Delims.Right = delims[0], delims[1]

	// Template filters
	foundation.Template.Filters = []foundation.Filter{
		foundation.Newline2BreakFilter(),
		foundation.RawFilter(),
	}

	// Request Middlewares
	foundation.Middlewares = []foundation.Middleware{
		foundation.RecoveryMiddleware(),
		foundation.LoggerMiddleware(),
		CookieSessionMiddleware(),
		SecureMiddleware(),
		ResponseHeaderMiddleware(),
		foundation.DebugPrintHeaderMiddleware(),
		DebugMiddleware(),
	}

	// Sync database scheme (create or migrate tables)
	orm := database.NewGorm()
	scheme.Sync(orm)
}
// SetContext sets foundation.Context to initialize controller.
func (c *RootController) SetContext(ctx foundation.Context) {
	c.RootController.SetContext(ctx)

	// Set database to context
	orm := database.NewGorm()
	accessor.SetDatabase(ctx, orm)
}