helper

package
v0.0.0-...-2fe84d8 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AccessExpiresIn token access expires in duration
	AccessExpiresIn = 12 * time.Hour
)

Functions

func CreateToken

func CreateToken(claims JwtClaims) (token map[string]string, err error)

CreateToken ...

Types

type JwtClaims

type JwtClaims struct {
	jwt.StandardClaims
	UserClaims
}

JwtClaims ...

func ParseToken

func ParseToken(token string) (*JwtClaims, error)

ParseToken ...

type StatsHandler

type StatsHandler struct{}

StatsHandler Handler defines the interface for the related stats handling (e.g., RPCs, connections).

func (*StatsHandler) HandleConn

func (h *StatsHandler) HandleConn(ctx context.Context, s stats.ConnStats)

HandleConn processes the Conn stats.

func (*StatsHandler) HandleRPC

func (h *StatsHandler) HandleRPC(ctx context.Context, s stats.RPCStats)

HandleRPC processes the RPC stats.

func (*StatsHandler) TagConn

func (h *StatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context

TagConn can attach some information to the given context. The returned context will be used for stats handling. For conn stats handling, the context used in HandleConn for this connection will be derived from the context returned. For RPC stats handling,

  • On server side, the context used in HandleRPC for all RPCs on this

connection will be derived from the context returned.

  • On client side, the context is not derived from the context returned.

func (*StatsHandler) TagRPC

func (h *StatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context

TagRPC can attach some information to the given context. The context used for the rest lifetime of the RPC will be derived from the returned context.

type UserClaims

type UserClaims struct {
	ClientID string // 客户端ID
	ID       string // 用户ID
	Name     string // 用户名
	Role     string // 当前角色
}

UserClaims 用户信息

Jump to

Keyboard shortcuts

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