Skip to content
GORM backend for gorilla sessions
Branch: master
Clone or download
Latest commit acb787b Mar 2, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.travis.yml Add go 1.12 Mar 2, 2019
LICENSE
README.md Add LICENSE Jan 6, 2016
gormstore.go Make sure context keys can’t collide with anything else Sep 30, 2016
gormstore_test.go
test

README.md

GORM backend for gorilla sessions

go get github.com/wader/gormstore

Documentation

http://www.godoc.org/github.com/wader/gormstore

Example

// initialize and setup cleanup
store := gormstore.New(gorm.Open(...), []byte("secret"))
// db cleanup every hour
// close quit channel to stop cleanup
quit := make(chan struct{})
go store.PeriodicCleanup(1*time.Hour, quit)
// in HTTP handler
func handlerFunc(w http.ResponseWriter, r *http.Request) {
  session, err := store.Get(r, "session")
  session.Values["user_id"] = 123
  store.Save(r, w, session)
  http.Error(w, "", http.StatusOK)
}

For more details see gormstore godoc documentation.

Testing

Just sqlite3 tests:

go test

All databases using docker:

./test

If docker is not local (docker-machine etc):

DOCKER_IP=$(docker-machine ip dev) ./test

License

gormstore is licensed under the MIT license. See LICENSE for the full license text.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.