mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-05 09:12:25 -06:00
[chore] Update all but bun libraries (#526)
* update all but bun libraries Signed-off-by: kim <grufwub@gmail.com> * remove my personal build script changes Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
parent
e06bf9cc9a
commit
b56dae8120
350 changed files with 305366 additions and 5943 deletions
153
vendor/github.com/gin-contrib/sessions/README.md
generated
vendored
153
vendor/github.com/gin-contrib/sessions/README.md
generated
vendored
|
|
@ -13,6 +13,7 @@ Gin middleware for session management with multi-backend support:
|
|||
- [Redis](#redis)
|
||||
- [memcached](#memcached)
|
||||
- [MongoDB](#mongodb)
|
||||
- [GoRM](#gorm)
|
||||
- [memstore](#memstore)
|
||||
- [PostgreSQL](#postgresql)
|
||||
|
||||
|
|
@ -249,12 +250,13 @@ func main() {
|
|||
|
||||
### MongoDB
|
||||
|
||||
#### mgo
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-contrib/sessions/mongo"
|
||||
"github.com/gin-contrib/sessions/mongo/mongomgo"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/globalsign/mgo"
|
||||
)
|
||||
|
|
@ -267,7 +269,54 @@ func main() {
|
|||
}
|
||||
|
||||
c := session.DB("").C("sessions")
|
||||
store := mongo.NewStore(c, 3600, true, []byte("secret"))
|
||||
store := mongomgo.NewStore(c, 3600, true, []byte("secret"))
|
||||
r.Use(sessions.Sessions("mysession", store))
|
||||
|
||||
r.GET("/incr", func(c *gin.Context) {
|
||||
session := sessions.Default(c)
|
||||
var count int
|
||||
v := session.Get("count")
|
||||
if v == nil {
|
||||
count = 0
|
||||
} else {
|
||||
count = v.(int)
|
||||
count++
|
||||
}
|
||||
session.Set("count", count)
|
||||
session.Save()
|
||||
c.JSON(200, gin.H{"count": count})
|
||||
})
|
||||
r.Run(":8000")
|
||||
}
|
||||
```
|
||||
|
||||
#### mongo-driver
|
||||
```
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-contrib/sessions/mongo/mongodriver"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
func main() {
|
||||
r := gin.Default()
|
||||
mongoOptions := options.Client().ApplyURI("mongodb://localhost:27017")
|
||||
client, err := mongo.NewClient(mongoOptions)
|
||||
if err != nil {
|
||||
// handle err
|
||||
}
|
||||
|
||||
if err := client.Connect(context.Background()); err != nil {
|
||||
// handle err
|
||||
}
|
||||
|
||||
c := client.Database("test").Collection("sessions")
|
||||
store := mongodriver.NewStore(c, 3600, true, []byte("secret"))
|
||||
r.Use(sessions.Sessions("mysession", store))
|
||||
|
||||
r.GET("/incr", func(c *gin.Context) {
|
||||
|
|
@ -322,46 +371,88 @@ func main() {
|
|||
}
|
||||
```
|
||||
|
||||
### GoRM
|
||||
|
||||
[embedmd]:# (_example/gorm/main.go go)
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gin-contrib/sessions"
|
||||
gormsessions "github.com/gin-contrib/sessions/gorm"
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db, err := gorm.Open(sqlite.Open("test.db"), &gorm.Config{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
store := gormsessions.NewStore(db, true, []byte("secret"))
|
||||
|
||||
r := gin.Default()
|
||||
r.Use(sessions.Sessions("mysession", store))
|
||||
|
||||
r.GET("/incr", func(c *gin.Context) {
|
||||
session := sessions.Default(c)
|
||||
var count int
|
||||
v := session.Get("count")
|
||||
if v == nil {
|
||||
count = 0
|
||||
} else {
|
||||
count = v.(int)
|
||||
count++
|
||||
}
|
||||
session.Set("count", count)
|
||||
session.Save()
|
||||
c.JSON(200, gin.H{"count": count})
|
||||
})
|
||||
r.Run(":8000")
|
||||
}
|
||||
```
|
||||
|
||||
### PostgreSQL
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-contrib/sessions/postgres"
|
||||
"github.com/gin-gonic/gin"
|
||||
"database/sql"
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-contrib/sessions/postgres"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
r := gin.Default()
|
||||
db, err := sql.Open("postgres", "postgresql://username:password@localhost:5432/database")
|
||||
if err != nil {
|
||||
// handle err
|
||||
}
|
||||
r := gin.Default()
|
||||
db, err := sql.Open("postgres", "postgresql://username:password@localhost:5432/database")
|
||||
if err != nil {
|
||||
// handle err
|
||||
}
|
||||
|
||||
store, err := postgres.NewStore(db, []byte("secret"))
|
||||
if err != nil {
|
||||
// handle err
|
||||
}
|
||||
store, err := postgres.NewStore(db, []byte("secret"))
|
||||
if err != nil {
|
||||
// handle err
|
||||
}
|
||||
|
||||
r.Use(sessions.Sessions("mysession", store))
|
||||
r.Use(sessions.Sessions("mysession", store))
|
||||
|
||||
r.GET("/incr", func(c *gin.Context) {
|
||||
session := sessions.Default(c)
|
||||
var count int
|
||||
v := session.Get("count")
|
||||
if v == nil {
|
||||
count = 0
|
||||
} else {
|
||||
count = v.(int)
|
||||
count++
|
||||
}
|
||||
session.Set("count", count)
|
||||
session.Save()
|
||||
c.JSON(200, gin.H{"count": count})
|
||||
})
|
||||
r.Run(":8000")
|
||||
r.GET("/incr", func(c *gin.Context) {
|
||||
session := sessions.Default(c)
|
||||
var count int
|
||||
v := session.Get("count")
|
||||
if v == nil {
|
||||
count = 0
|
||||
} else {
|
||||
count = v.(int)
|
||||
count++
|
||||
}
|
||||
session.Set("count", count)
|
||||
session.Save()
|
||||
c.JSON(200, gin.H{"count": count})
|
||||
})
|
||||
r.Run(":8000")
|
||||
}
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue