https://github.com/bh90210/go-sessions-stores
Dgraph & MongoDB implementations for https://github.com/kataras/go-sessions
https://github.com/bh90210/go-sessions-stores
dgraph go go-sessions mongodb store
Last synced: 7 months ago
JSON representation
Dgraph & MongoDB implementations for https://github.com/kataras/go-sessions
- Host: GitHub
- URL: https://github.com/bh90210/go-sessions-stores
- Owner: bh90210
- License: unlicense
- Created: 2021-01-25T02:17:54.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-01T08:00:47.000Z (about 5 years ago)
- Last Synced: 2024-11-15T06:09:05.068Z (over 1 year ago)
- Topics: dgraph, go, go-sessions, mongodb, store
- Language: Go
- Homepage:
- Size: 40 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-sessions-stores
[](https://goreportcard.com/report/github.com/bh90210/go-sessions-stores)
Dgraph & MongoDB implementations for [kataras/go-sessions](https://github.com/kataras/go-sessions).
## How to use
For a full documentation of the library see the [original repository](https://github.com/kataras/go-sessions).
Full examples can be found in the [examples](https://github.com/bh90210/go-sessions-stores/tree/main/examples) folder.
### Mongo
[](https://pkg.go.dev/github.com/bh90210/go-sessions-stores/mongostore)
To include `mongostore` run
```sh
go get github.com/bh90210/go-sessions-stores/mongostore
```
#### Example
```go
// replace with your running mongo server settings:
cred := options.Credential{
AuthSource: "admin",
Username: "user",
Password: "password",
}
clientOpts := options.Client().ApplyURI("mongodb://127.0.0.1:27017").SetAuth(cred)
db, _ := mongostore.New(clientOpts, "sessions")
sess := sessions.New(sessions.Config{Cookie: "sessionscookieid"})
sess.UseDatabase(db)
```
### Dgraph
[](https://pkg.go.dev/github.com/bh90210/go-sessions-stores/dgraphstore)
To include `dgraphstore` run
```sh
go get github.com/bh90210/go-sessions-stores/dgraphstore
```
#### Example
```go
// replace with your server settings:
conn, _ := grpc.Dial("127.0.0.1:9080", grpc.WithInsecure())
db, _ := dgraphstore.NewFromDB(conn)
sess := sessions.New(sessions.Config{Cookie: "sessionscookieid"})
sess.UseDatabase(db)
```