...

Source file src/github.com/gin-contrib/sessions/postgres/postgres.go

Documentation: github.com/gin-contrib/sessions/postgres

     1  package postgres
     2  
     3  import (
     4  	"database/sql"
     5  	"github.com/antonlindstrom/pgstore"
     6  	"github.com/gin-contrib/sessions"
     7  )
     8  
     9  type Store interface {
    10  	sessions.Store
    11  }
    12  
    13  type store struct {
    14  	*pgstore.PGStore
    15  }
    16  
    17  var _ Store = new(store)
    18  
    19  func NewStore(db *sql.DB, keyPairs ...[]byte) (Store, error) {
    20  	p, err := pgstore.NewPGStoreFromPool(db, keyPairs...)
    21  	if err != nil {
    22  		return nil, err
    23  	}
    24  
    25  	return &store{p}, nil
    26  }
    27  
    28  func (s *store) Options(options sessions.Options) {
    29  	s.PGStore.Options = options.ToGorillaOptions()
    30  }
    31  

View as plain text