Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/wader/gormstore

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/wader/gormstore

  • v0.0.0-20240711174339-ed3e4c58a961
  • Source
  • Go
  • Socket score

Version published
Created
Source
GORM backend for gorilla sessions

For gorm v2 use:

import "github.com/wader/gormstore/v2"

For gorm v1 use:

import "github.com/wader/gormstore"
Documentation

https://pkg.go.dev/github.com/wader/gormstore?tab=doc

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 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.

FAQs

Package last updated on 11 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc