cookie

package
v0.2.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2019 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CookieName cookie 名稱
	CookieName = "king011_auto_deploy_grpc_session"
)
View Source
const (
	// FileName 配置檔案名稱
	FileName = "securecookie.json"
)

Variables

This section is empty.

Functions

func Decode

func Decode(name, value string, dst interface{}) error

Decode 解密一個 cookie

func Encode

func Encode(name string, value interface{}) (string, error)

Encode 加密一個 cookie

func Generate

func Generate() (hashKey []byte, blockKey []byte)

Generate 創建隨機的 key

func IniClient

func IniClient(filename string) (e error)

IniClient 以 客戶端 測試模式 初始化

func Init

func Init(filename string, maxAge int64)

Init 初始化

func IsInit

func IsInit() bool

IsInit 返回 是否 初始化

func Save

func Save(filename string, hashKey []byte, blockKey []byte) (e error)

Save 存儲 key 到 檔案

Types

type Session

type Session struct {
	// 用戶登入名稱
	Name string

	// 是否是管理員
	Root bool

	// session 創建時間
	Time time.Time
}

Session 客戶連接 信息

func FromContext

func FromContext(ctx context.Context) (session *Session, e error)

FromContext 由Context值 恢復session

func FromCookie

func FromCookie(val string) (session *Session, e error)

FromCookie 由cookie值 恢復session

func FromMD

func FromMD(md metadata.MD) (session *Session, e error)

FromMD 由cookie值 恢復session

func (*Session) Cookie

func (s *Session) Cookie() (string, error)

Cookie 爲 session 創建 cookie 值

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL