Example #1
0
// preparebase.Context sets view,config and model on the ctx.
func (r *Router) prepareContext(ctx *base.Context) {
	if r.Options != nil {
		if r.Options.View != nil {
			ctx.Set(r.Options.View)
		}
		if r.Options.Config != nil {
			ctx.Cfg = r.Options.Config
		}
		if r.Options.Model != nil {
			ctx.DB = r.Options.Model
		}
		if r.Options.Log != nil {
			ctx.Log = r.Options.Log
		}
		if r.Options.SessionStore != nil {
			ctx.SessionStore = r.Options.SessionStore
		}
	}

	// It is a good idea to ensure that a well prepared context always has the
	// Log field set.
	if ctx.Log == nil {
		ctx.Log = defaultLogger
	}
}