api

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func Init

func Init(jwtKey string)

func Process

func Process(ctx *gin.Context, d interface{}, handle handler, checkers ...checker)

func ProcessCheckToken

func ProcessCheckToken(ctx *gin.Context, d interface{}, handle handler)

func Respond

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

Types

type Request

type Request struct {
	Token string      `json:"token"`
	Data  interface{} `json:"data"`

	Claim *SignClaim `json:"-"`
}

type Response

type Response struct {
	Code        int         `json:"code"`
	Description string      `json:"description"`
	Data        interface{} `json:"data"`
}

type SignClaim

type SignClaim struct {
	jwt.RegisteredClaims

	UserID   int64
	Nickname string
}

func NewClaimFromToken

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

func NewSignClaim

func NewSignClaim(userID int64, nickname string) *SignClaim

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