1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00
cowyo/vendor/github.com/gin-contrib/sessions/mongo.go

32 lines
644 B
Go
Raw Normal View History

2017-10-03 21:43:55 +03:00
package sessions
import (
"github.com/gorilla/sessions"
"github.com/kidstuff/mongostore"
mgo "gopkg.in/mgo.v2"
)
type MongoStore interface {
Store
}
func NewMongoStore(c *mgo.Collection, maxAge int, ensureTTL bool, keyPairs ...[]byte) MongoStore {
store := mongostore.NewMongoStore(c, maxAge, ensureTTL, keyPairs...)
return &mongoStore{store}
}
type mongoStore struct {
*mongostore.MongoStore
}
func (c *mongoStore) Options(options Options) {
c.MongoStore.Options = &sessions.Options{
Path: options.Path,
Domain: options.Domain,
MaxAge: options.MaxAge,
Secure: options.Secure,
HttpOnly: options.HttpOnly,
}
}