Browse Source

feat(go): restore method;

Vishal Dalwadi 4 tháng trước cách đây
mục cha
commit
a7fd5ccfe0
1 tập tin đã thay đổi với 4 bổ sung0 xóa
  1. 4 0
      db/db.go

+ 4 - 0
db/db.go

@@ -75,6 +75,10 @@ func Middleware(next http.Handler) http.Handler {
 //
 // The function panics, if a connection does not exist.
 func FromContext(ctx context.Context) *gorm.DB {
+	db, ok := ctx.Value(dbCtxKey).(*gorm.DB)
+	if !ok {
+		panic(ErrDBNotFound)
+	}
 
 	return db
 }