middleware

package
v0.0.0-...-be30394 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMiddleware

func AddMiddleware(middleware Middleware)

func Authenticator

func Authenticator(c *gin.Context) (interface{}, error)

func Authorizator

func Authorizator(data interface{}, c *gin.Context) bool

func IdentityHandler

func IdentityHandler(c *gin.Context) interface{}

func LoginResponse

func LoginResponse(c *gin.Context, code int, token string, expire time.Time)

func LogoutResponse

func LogoutResponse(c *gin.Context, code int)

func PayloadFunc

func PayloadFunc(data interface{}) jwt.MapClaims

func RecordMetrics

func RecordMetrics(method, uri string, success bool, httpCode, businessCode int, costSeconds float64, traceId string)

RecordMetrics 记录指标

func RefreshResponse

func RefreshResponse(c *gin.Context, code int, token string, expire time.Time)

func Unauthorized

func Unauthorized(c *gin.Context, code int, msg string)

Types

type Credential

type Credential struct {
	UserName string
	Roles    []*Role
}

type Login

type Login struct {
	Username string `form:"username" json:"username" binding:"required"`
	Password string `form:"password" json:"password" binding:"required"`
}

type Middleware

type Middleware interface {
	Init()
	Apply(r *gin.Engine)
	Get() gin.HandlerFunc
	Destroy()
}

func GetMiddlewares

func GetMiddlewares() []Middleware

type Role

type Role struct {
	gorm.Model
	Name string
}

Jump to

Keyboard shortcuts

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