httputils

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitSession added in v1.4.3

func InitSession(options *SessionOptions)

Types

type CookieOptions

type CookieOptions struct {
	AesKey   string //加密KEY
	Domain   string //设置域
	Path     string //设置路径
	Secure   bool   //是否安全传送
	HttpOnly bool   //是否开启只用于HTTP
}

type HttpCookie

type HttpCookie struct {
	// contains filtered or unexported fields
}

cookie 操作

func NewHttpCookie

func NewHttpCookie(req *http.Request, writer http.ResponseWriter, options *CookieOptions) *HttpCookie

func (*HttpCookie) Delete

func (c *HttpCookie) Delete(name string)

删除一个COOKIE

func (*HttpCookie) Get

func (c *HttpCookie) Get(name string) (string, error)

得到一个COOKIE

func (*HttpCookie) Set

func (c *HttpCookie) Set(name string, val string, maxAge int)

设置一个COOKIE maxAge

type HttpSession

type HttpSession struct {
	// contains filtered or unexported fields
}

func NewHttpSession

func NewHttpSession(cookie *HttpCookie) *HttpSession

func (*HttpSession) Flush

func (s *HttpSession) Flush()

将SESSION 回写

func (*HttpSession) Get

func (s *HttpSession) Get(name string) string

设置一个Session 值

func (*HttpSession) Set

func (s *HttpSession) Set(name string, val string)

设置一个Session 值

func (*HttpSession) Start

func (s *HttpSession) Start()

开始Session

type SessionData

type SessionData struct {
	Key    string  `json:"key"`    //session key
	Value  utils.M `json:"data"`   //session value
	Expire int     `json:"expire"` //过期时间
}

session 数据

func (*SessionData) ParseJson

func (m *SessionData) ParseJson(data []byte) error

func (*SessionData) ParseJsonString

func (m *SessionData) ParseJsonString(data string) error

func (*SessionData) ToJson

func (m *SessionData) ToJson() []byte

func (*SessionData) ToJsonString

func (m *SessionData) ToJsonString() string

type SessionOptions

type SessionOptions struct {
	StorageType  SessionType   //Session 存储类型
	SurvivalTime time.Duration //Session 存活时间
	CookieName   string        //Session cookie name
}

session 选项

type SessionType

type SessionType int
const (
	SessionMem SessionType = iota
	SessionRedis
	SessionFile
)

Jump to

Keyboard shortcuts

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