Пример #1
0
func (m *Mother) Database() db.DatabaseInterface {
	env := NewEnvironment()
	database := v1models.NewDatabase(m.SQLDatabase(), v1models.Config{
		DefaultTemplatePath: path.Join(env.RootPath, "templates", "default.json"),
	})

	if env.DBLoggingEnabled {
		database.TraceOn("[DB]", log.New(os.Stdout, "", 0))
	}

	return database
}
Пример #2
0
func (ware DatabaseAllocator) ServeHTTP(w http.ResponseWriter, req *http.Request, context stack.Context) bool {
	db := models.NewDatabase(ware.DB, models.Config{})

	logger := gorpCompatibleLogger{
		logger: context.Get("logger").(lager.Logger).WithData(lager.Data{
			VCAPRequestIDKey: context.Get(VCAPRequestIDKey),
		}),
	}

	if ware.Trace {
		db.TraceOn("", logger)
	}

	context.Set("database", db)
	return true
}