Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update examples for /v2 refactor. #32

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions examples/fastglue-goredis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ module github.com/vividvilla/simplesessions/examples/fastglue-goredis
go 1.16

require (
github.com/go-redis/redis/v8 v8.11.1
github.com/valyala/fasthttp v1.9.0
github.com/vividvilla/simplesessions v0.2.0
github.com/zerodha/fastglue v1.6.6
github.com/fasthttp/router v1.5.0 // indirect
github.com/klauspost/compress v1.17.8 // indirect
github.com/redis/go-redis/v9 v9.5.1
github.com/valyala/fasthttp v1.52.0
github.com/vividvilla/simplesessions/stores/goredis/v9 v9.0.0
github.com/vividvilla/simplesessions/v2 v2.0.0
github.com/zerodha/fastglue v1.8.0
)
6 changes: 3 additions & 3 deletions examples/fastglue-goredis/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"net/http"
"time"

"github.com/go-redis/redis/v8"
"github.com/redis/go-redis/v9"
"github.com/valyala/fasthttp"
"github.com/vividvilla/simplesessions"
redisstore "github.com/vividvilla/simplesessions/stores/goredis"
redisstore "github.com/vividvilla/simplesessions/stores/goredis/v9"
"github.com/vividvilla/simplesessions/v2"
"github.com/zerodha/fastglue"
)

Expand Down
20 changes: 11 additions & 9 deletions examples/fasthttp-redis/go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
module github.com/vividvilla/simplesessions/examples/fasthttp-redis

go 1.14

require (
github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6 // indirect
github.com/alicebob/miniredis v0.0.0-20180903194238-a6a1e4126522 // indirect
github.com/gomodule/redigo v2.0.0+incompatible
github.com/klauspost/compress v1.4.0 // indirect
github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e // indirect
github.com/valyala/bytebufferpool v0.0.0-20160817181652-e746df99fe4a // indirect
github.com/valyala/fasthttp v0.0.0-20180901052036-d7688109a57b
github.com/vividvilla/simplesessions v0.0.1
github.com/vividvilla/simplesessions/stores/redis v0.0.0-20180905073812-64bb2453ba8a
github.com/yuin/gopher-lua v0.0.0-20180827083657-b942cacc89fe // indirect
github.com/valyala/fasthttp v1.52.0
github.com/vividvilla/simplesessions/stores/redis/v2 v2.0.0
github.com/vividvilla/simplesessions/v2 v2.0.0
)

require (
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/klauspost/compress v1.17.6 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
)
4 changes: 2 additions & 2 deletions examples/fasthttp-redis/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/gomodule/redigo/redis"
"github.com/valyala/fasthttp"
"github.com/vividvilla/simplesessions"
redisstore "github.com/vividvilla/simplesessions/stores/redis"
redisstore "github.com/vividvilla/simplesessions/stores/redis/v2"
"github.com/vividvilla/simplesessions/v2"
)

var (
Expand Down
6 changes: 4 additions & 2 deletions examples/nethttp-inmemory/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/vividvilla/simplesessions/examples/nethttp-inmemory

go 1.14

require (
github.com/vividvilla/simplesessions v0.0.1
github.com/vividvilla/simplesessions/stores/memory v0.0.0-20180905073812-64bb2453ba8a
github.com/vividvilla/simplesessions/stores/memory/v2 v2.0.0
github.com/vividvilla/simplesessions/v2 v2.0.0
)
4 changes: 2 additions & 2 deletions examples/nethttp-inmemory/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"log"
"net/http"

"github.com/vividvilla/simplesessions"
"github.com/vividvilla/simplesessions/stores/memory"
"github.com/vividvilla/simplesessions/stores/memory/v2"
"github.com/vividvilla/simplesessions/v2"
)

var (
Expand Down
9 changes: 4 additions & 5 deletions examples/nethttp-redis/go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
module github.com/vividvilla/simplesessions/examples/nethttp-redis

go 1.14

require (
github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6 // indirect
github.com/alicebob/miniredis v0.0.0-20180903194238-a6a1e4126522 // indirect
github.com/gomodule/redigo v2.0.0+incompatible
github.com/vividvilla/simplesessions v0.0.1
github.com/vividvilla/simplesessions/stores/redis v0.0.0-20180905073812-64bb2453ba8a
github.com/yuin/gopher-lua v0.0.0-20180827083657-b942cacc89fe // indirect
github.com/vividvilla/simplesessions/stores/redis/v2 v2.0.0
github.com/vividvilla/simplesessions/v2 v2.0.0
)
4 changes: 2 additions & 2 deletions examples/nethttp-redis/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"time"

"github.com/gomodule/redigo/redis"
"github.com/vividvilla/simplesessions"
redisstore "github.com/vividvilla/simplesessions/stores/redis"
redisstore "github.com/vividvilla/simplesessions/stores/redis/v2"
"github.com/vividvilla/simplesessions/v2"
)

var (
Expand Down
9 changes: 6 additions & 3 deletions examples/nethttp-secure-cookie/go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
module github.com/vividvilla/simplesessions/examples/nethttp-secure-cookie

go 1.14

require (
github.com/gorilla/securecookie v1.1.1 // indirect
github.com/vividvilla/simplesessions v0.0.1
github.com/vividvilla/simplesessions/stores/securecookie v0.0.0-20180905073812-64bb2453ba8a
github.com/vividvilla/simplesessions/stores/securecookie/v2 v2.0.0
github.com/vividvilla/simplesessions/v2 v2.0.0
)

require github.com/gorilla/securecookie v1.1.2 // indirect
25 changes: 18 additions & 7 deletions examples/nethttp-secure-cookie/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ import (
"log"
"net/http"

"github.com/vividvilla/simplesessions"
"github.com/vividvilla/simplesessions/stores/securecookie"
"github.com/vividvilla/simplesessions/stores/securecookie/v2"
"github.com/vividvilla/simplesessions/v2"
)

var (
sessionManager *simplesessions.Manager

store = securecookie.New(
[]byte("0dIHy6S2uBuKaNnTUszB218L898ikGYA"),
[]byte("0dIHy6S2uBuKaNnTUszB218L898ikGYA"),
)

testKey = "abc123"
testValue = 123456
)
Expand All @@ -29,7 +34,16 @@ func setHandler(w http.ResponseWriter, r *http.Request) {
return
}

if err = sess.Commit(); err != nil {
// For securecookies, ID() of the session is the encoded cookie
// data itself.
v, err := store.Flush(sess.ID())
if err != nil {
http.Error(w, err.Error(), 500)
return
}

// Write the cookie.
if err := sess.WriteCookie(v); err != nil {
http.Error(w, err.Error(), 500)
return
}
Expand Down Expand Up @@ -71,10 +85,7 @@ func setCookie(cookie *http.Cookie, w interface{}) error {

func main() {
sessionManager = simplesessions.New(simplesessions.Options{})
sessionManager.UseStore(securecookie.New(
[]byte("0dIHy6S2uBuKaNnTUszB218L898ikGYA"),
[]byte("0dIHy6S2uBuKaNnTUszB218L898ikGYA"),
))
sessionManager.UseStore(store)

sessionManager.RegisterGetCookie(getCookie)
sessionManager.RegisterSetCookie(setCookie)
Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module github.com/vividvilla/simplesessions/v2

require github.com/stretchr/testify v1.9.0
require (
github.com/stretchr/testify v1.9.0
github.com/valyala/fasthttp v1.40.0
)

go 1.14
4 changes: 2 additions & 2 deletions go.work
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
go 1.18
go 1.21

use (
.
./conv
./stores/goredis
./stores/memory
./stores/redis
./stores/securecookie
./stores/memory
)
Loading