Initial patch

This commit is contained in:
Your Name 2018-09-27 15:15:50 +00:00
parent a407030ba6
commit 272018cf22
1 changed files with 5 additions and 5 deletions

View File

@ -3,12 +3,12 @@ package pgstore
import (
"database/sql"
"encoding/base32"
"github.com/jmoiron/sqlx"
"github.com/pkg/errors"
"net/http"
"strings"
"time"
"github.com/pkg/errors"
"github.com/gorilla/securecookie"
"github.com/gorilla/sessions"
@ -21,7 +21,7 @@ type PGStore struct {
Codecs []securecookie.Codec
Options *sessions.Options
Path string
DbPool *sql.DB
DbPool *sqlx.DB
}
// PGSession type
@ -37,7 +37,7 @@ type PGSession struct {
// NewPGStore creates a new PGStore instance and a new database/sql pool.
// This will also create in the database the schema needed by pgstore.
func NewPGStore(dbURL string, keyPairs ...[]byte) (*PGStore, error) {
db, err := sql.Open("postgres", dbURL)
db, err := sqlx.Open("postgres", dbURL)
if err != nil {
// Ignore and return nil.
return nil, err
@ -48,7 +48,7 @@ func NewPGStore(dbURL string, keyPairs ...[]byte) (*PGStore, error) {
// NewPGStoreFromPool creates a new PGStore instance from an existing
// database/sql pool.
// This will also create the database schema needed by pgstore.
func NewPGStoreFromPool(db *sql.DB, keyPairs ...[]byte) (*PGStore, error) {
func NewPGStoreFromPool(db *sqlx.DB, keyPairs ...[]byte) (*PGStore, error) {
dbStore := &PGStore{
Codecs: securecookie.CodecsFromPairs(keyPairs...),
Options: &sessions.Options{