소스 검색

feat(go): restore method;

Vishal Dalwadi 4 달 전
부모
커밋
a7fd5ccfe0
1개의 변경된 파일4개의 추가작업 그리고 0개의 파일을 삭제
  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
 }