diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2025-02-03 01:12:45 -0500 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2025-02-03 01:12:45 -0500 |
commit | 5389e1a5d26fdbf2441fa5a1e101999e8449b9d1 (patch) | |
tree | 069cd37cb8e556c1ba3b47c3ea8576a1aa91ea2c /internal/storage/db.go |
Batman
Diffstat (limited to 'internal/storage/db.go')
-rw-r--r-- | internal/storage/db.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/storage/db.go b/internal/storage/db.go new file mode 100644 index 0000000..06fe31c --- /dev/null +++ b/internal/storage/db.go @@ -0,0 +1,18 @@ +package storage + +import ( + "context" + "database/sql" + "log/slog" + + "github.com/ChausseBenjamin/rafta/internal/util" +) + +func GetDB(ctx context.Context) *sql.DB { + db, ok := ctx.Value(util.DBKey).(*sql.DB) + if !ok { + slog.Error("Unable to retrieve database from context") + return nil + } + return db +} |