app

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateToken

func GenerateToken(user *ms.User) (string, error)

func GetJWTSecret

func GetJWTSecret() []byte

func GetPage

func GetPage(c *gin.Context) int

func GetPageInfo added in v0.2.0

func GetPageInfo(c *gin.Context) (page, pageSize int)

func GetPageOffset

func GetPageOffset(c *gin.Context) (offset, limit int)

func GetPageSize

func GetPageSize(c *gin.Context) int

func IssuerFrom added in v0.5.0

func IssuerFrom(data string) string

Types

type Claims

type Claims struct {
	UID      int64  `json:"uid"`
	Username string `json:"username"`
	jwt.RegisteredClaims
}

func ParseToken

func ParseToken(token string) (res *Claims, err error)

type Pager

type Pager struct {
	Page      int   `json:"page"`
	PageSize  int   `json:"page_size"`
	TotalRows int64 `json:"total_rows"`
}

type Response

type Response struct {
	Ctx *gin.Context
}

func NewResponse

func NewResponse(ctx *gin.Context) *Response

func (*Response) ToErrorResponse

func (r *Response) ToErrorResponse(err *xerror.Error)

func (*Response) ToResponse

func (r *Response) ToResponse(data any)

func (*Response) ToResponseList

func (r *Response) ToResponseList(list any, totalRows int64)

type ValidError

type ValidError struct {
	Message string
}

func (*ValidError) Error

func (v *ValidError) Error() string

type ValidErrors

type ValidErrors []*ValidError

func BindAndValid

func BindAndValid(c *gin.Context, v any) (bool, ValidErrors)

func (ValidErrors) Error

func (v ValidErrors) Error() string

func (ValidErrors) Errors

func (v ValidErrors) Errors() []string

Jump to

Keyboard shortcuts

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