mongostore/store.go

41 lines
899 B
Go
Raw Normal View History

2020-03-22 01:01:55 +01:00
package mongostore
import (
"context"
"net/http"
"time"
"github.com/gorilla/securecookie"
"github.com/gorilla/sessions"
"go.mongodb.org/mongo-driver/mongo"
)
type MongoStore struct {
client *mongo.Client
Codecs []securecookie.Codec
Options *sessions.Options
}
func NewMongoStore(client *mongo.Client) *MongoStore {
s := new(MongoStore)
s.client = client
return s
}
func (s *MongoStore) New(r *http.Request, name string) (*sessions.Session, error) {
panic("not implemented")
}
func (s *MongoStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error {
panic("not implemented")
}
func (s *MongoStore) Delete(r *http.Request, w http.ResponseWriter, session *sessions.Session) error {
panic("not implemented")
}
func (s *MongoStore) Close() error {
ctx, _ := context.WithTimeout(context.Background(), 3*time.Second)
return s.client.Disconnect(ctx)
}