Documentation ¶
Overview ¶
Package ginsession is gin server session middleware.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
Default = StdConfig("default").Build()
)
Functions ¶
func Cookie ¶
func Cookie() gin.HandlerFunc
func CookieName ¶ added in v1.0.10
func CookieName() string
func CookieNames ¶ added in v1.0.10
func CookieNames() []string
func Redis ¶
func Redis() gin.HandlerFunc
Types ¶
type Config ¶
type Config struct { Redis string `config:"redis"` CookieName string `config:"cookieName" desc:"cookie name"` CookieNames []string `config:"cookieNames" desc:"cookie names"` KeyPair string `config:"keyPair" desc:"cookie value encrypt key pair"` KeyPrefix string `config:"keyPrefix" desc:"redis save key prefix"` MaxLen int `config:"maxLen" desc:"max val length"` // contains filtered or unexported fields }
Config 配置
type GinSession ¶
type GinSession struct {
// contains filtered or unexported fields
}
func (*GinSession) Cookie ¶
func (s *GinSession) Cookie() gin.HandlerFunc
Example ¶
package main import ( "github.com/boxgo/box/pkg/logger" "github.com/boxgo/box/pkg/server/ginserver" "github.com/boxgo/box/pkg/server/ginserver/mid/ginsession" ) func main() { ginserver.Use(ginsession.Cookie()) ginserver.GET("/ping", func(ctx *ginserver.Context) { ctx.Data(200, "text/plain", []byte("pong")) }) if err := ginserver.Run(); err != nil { logger.Fatal(err) } }
Output:
func (*GinSession) CookieName ¶ added in v1.0.10
func (s *GinSession) CookieName() string
func (*GinSession) CookieNames ¶ added in v1.0.10
func (s *GinSession) CookieNames() []string
func (*GinSession) Redis ¶
func (s *GinSession) Redis() gin.HandlerFunc
Example ¶
package main import ( "github.com/boxgo/box/pkg/logger" "github.com/boxgo/box/pkg/server/ginserver" "github.com/boxgo/box/pkg/server/ginserver/mid/ginsession" ) func main() { ginserver.Use(ginsession.Redis()) ginserver.GET("/ping", func(ctx *ginserver.Context) { ctx.Data(200, "text/plain", []byte("pong")) }) if err := ginserver.Run(); err != nil { logger.Fatal(err) } }
Output:
Click to show internal directories.
Click to hide internal directories.