api

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SignClaimKey = "sign-claim"
)

Variables

View Source
var (
	ErrParseToken = errors.New("parse token")
)
View Source
var (
	JwtKey string
)

Functions

func Abort added in v0.10.0

func Abort(ctx *gin.Context, data interface{}, err error)

Abort 中间件应该使用该方法

func Init

func Init(jwtKey string)

func Respond

func Respond(ctx *gin.Context, data interface{}, err error)

Types

type Response

type Response struct {
	Code int         `json:"code,omitempty"`
	Desc string      `json:"desc,omitempty"`
	Msg  string      `json:"msg,omitempty"`
	Data interface{} `json:"data,omitempty"`
}

type SignClaim

type SignClaim struct {
	jwt.RegisteredClaims

	UserID   int64
	Nickname string
}

func NewSignClaim

func NewSignClaim(userID int64, nickname string) *SignClaim

func NewSignClaimFromToken added in v0.10.0

func NewSignClaimFromToken(sign string) (*SignClaim, error)

func (*SignClaim) Token

func (c *SignClaim) Token() (string, error)

Jump to

Keyboard shortcuts

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