middleware

package
v0.0.0-...-cfbc2f4 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Encode

func Base64Encode(username, password string) string

Base64Encode 将username和password进行base64加密编码

func RequestDetailsLog

func RequestDetailsLog(h http.HandlerFunc) http.HandlerFunc

RequestDetailsLog 打印请求与返回详细日志

func ServiceConSumeTimeLog

func ServiceConSumeTimeLog(h http.HandlerFunc) http.HandlerFunc

ServiceConSumeTimeLog 打印服务耗时

Types

type BaseUser

type BaseUser struct {
	Name string
	Pwd  string
}

BaseUser 用户元数据

func (BaseUser) BasicAuth

func (u BaseUser) BasicAuth(h http.HandlerFunc) http.HandlerFunc

BasicAuth 简单的身份认证,校验通过则继续下层业务逻辑,不通过则401

type Session

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

Session session原子

type SessionManager

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

SessionManager session管理对象

func NewSessionManager

func NewSessionManager(cookieName string, maxLifeTime int64) *SessionManager

NewSessionManager 新建session管理并将其返回,同时预设定时清理过期session

func (*SessionManager) CheckCookieValid

func (manager *SessionManager) CheckCookieValid(w http.ResponseWriter, r *http.Request) (string, error)

CheckCookieValid 根据request校验cookie对应的session是否存在或有效

func (*SessionManager) EndSession

func (manager *SessionManager) EndSession(w http.ResponseWriter, r *http.Request)

EndSession 结束request中包含的session并设置到response的cookie中

func (*SessionManager) EndSessionByID

func (manager *SessionManager) EndSessionByID(sessionID string)

EndSessionByID 结束指定sessionID的session

func (*SessionManager) GetSessionValue

func (manager *SessionManager) GetSessionValue(sessionID string, key interface{}) (interface{}, error)

GetSessionValue 根据sessionID和key查询存放对应的数据

func (*SessionManager) NewSession

func (manager *SessionManager) NewSession(w http.ResponseWriter, r *http.Request, sessionValues map[interface{}]interface{}) string

NewSession 新建一个session并入库,将其设置到response的cookie,返回其sessionID

func (*SessionManager) NewSessionID

func (manager *SessionManager) NewSessionID() string

NewSessionID 返回一个随机构建的sessionID

func (*SessionManager) SessionGC

func (manager *SessionManager) SessionGC()

SessionGC 定期清理过期session

Jump to

Keyboard shortcuts

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