|
|
@ -71,11 +71,14 @@ func DatabaseFromContext(ctx context.Context) (db DB, ok bool) {
|
|
|
|
// MustDatabaseFromContext returns the current database from the given context.
|
|
|
|
// MustDatabaseFromContext returns the current database from the given context.
|
|
|
|
// It will panic if it's not in the context.
|
|
|
|
// It will panic if it's not in the context.
|
|
|
|
func MustDatabaseFromContext(ctx context.Context) DB {
|
|
|
|
func MustDatabaseFromContext(ctx context.Context) DB {
|
|
|
|
if db, ok := DatabaseFromContext(ctx); !ok {
|
|
|
|
var (
|
|
|
|
|
|
|
|
db DB
|
|
|
|
|
|
|
|
ok bool
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
if db, ok = DatabaseFromContext(ctx); !ok {
|
|
|
|
panic("acme database is not in the context")
|
|
|
|
panic("acme database is not in the context")
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return db
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return db
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// MockDB is an implementation of the DB interface that should only be used as
|
|
|
|
// MockDB is an implementation of the DB interface that should only be used as
|
|
|
|