A session store backend for gorilla/sessions - src using Etcd.
Depends on etcd client Etcd-client.
go get github.com/shampur/etcdstore
Available on godoc.org.
See http://www.gorillatoolkit.org/pkg/sessions for full documentation on underlying interface.
// Fetch new store.
addrs := []string{"127.0.0.1:2379"}
store := NewEtcdStore([]string{"http://127.0.0.1:2379"}, "session-name", []byte("something-very-secret")),
// Get a session.
session, err := store.Get(req, "session-key")
if err != nil {
log.Error(err.Error())
}
// Add a value.
session.Values["foo"] = "bar"
// Save.
if err = sessions.Save(req, rsp); err != nil {
t.Fatalf("Error saving session: %v", err)
}
// Delete session.
session.Options.MaxAge = -1
if err = sessions.Save(req, rsp); err != nil {
t.Fatalf("Error saving session: %v", err)
}