middleware

package
v0.0.0-...-79307e8 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2021 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	B  = 1
	KB = 1024 * B
	MB = 1024 * KB
	GB = 1024 * MB
)

Variables

View Source
var CasbinExclude = []UrlInfo{
	{Url: "/api/v1/dict/type-option-select", Method: "GET"},
	{Url: "/api/v1/dict-data/option-select", Method: "GET"},

	{Url: "/api/v1/deptTree", Method: "GET"},

	{Url: "/api/v1/menu-role", Method: "GET"},

	{Url: "/api/v1/configKey/:configKey", Method: "GET"},
	{Url: "/api/v1/app-config", Method: "GET"},

	{Url: "/api/v1/getinfo", Method: "GET"},
	{Url: "/api/v1/user/profile", Method: "GET"},
	{Url: "/api/v1/user/avatar", Method: "POST"},
	{Url: "/api/v1/user/pwd", Method: "PUT"},
	{Url: "/api/v1/user/status", Method: "PUT"},

	{Url: "/api/v1/roleMenuTreeSelect/:roleId", Method: "GET"},
	{Url: "/api/v1/roleDeptTreeSelect/:roleId", Method: "GET"},
	{Url: "/api/v1/public/uploadFile", Method: "POST"},

	{Url: "/api/v1/captcha", Method: "GET"},
	{Url: "/api/v1/login", Method: "POST"},
	{Url: "/api/v1/logout", Method: "POST"},
	{Url: "/api/v1/refresh_token", Method: "GET"},
	{Url: "/metrics", Method: "GET"},
	{Url: "/health", Method: "GET"},
	{Url: "/", Method: "GET"},
	{Url: "/info", Method: "GET"},
	{Url: "/server-monitor", Method: "GET"},
}

CasbinExclude casbin 排除的路由列表

Functions

func AuthCheckRole

func AuthCheckRole() gin.HandlerFunc

AuthCheckRole 权限检查中间件

func AuthInit

func AuthInit(prefix string) (*jwt.GinJWTMiddleware, error)

AuthInit jwt验证new

func CustomError

func CustomError(c *gin.Context)

func GenerateCaptchaHandler

func GenerateCaptchaHandler(c *gin.Context)

GenerateCaptchaHandler 获取验证码 @Summary 获取验证码 @Description 获取验证码 @Tags 登陆 @Success 200 {object} response.Response{data=string,id=string,msg=string} "{"code": 200, "data": [...]}" @Router /api/v1/captcha [get]

func GetHourDiffer

func GetHourDiffer(startTime, endTime string) int64

获取相差时间

func GinWrapper

func GinWrapper(handler http.Handler) gin.HandlerFunc

GinWrapper http.Handler 转换成 gin.HandlerFunc

func InitMiddleware

func InitMiddleware(r *gin.Engine)

func LoggerToFile

func LoggerToFile() gin.HandlerFunc

LoggerToFile 日志记录到文件

func Metrics

func Metrics() gin.HandlerFunc

Metrics returns a Gin measuring middleware.

func NoCache

func NoCache(c *gin.Context)

NoCache is a middleware function that appends headers to prevent the client from caching the HTTP response.

func Options

func Options(c *gin.Context)

Options is a middleware function that appends headers for options requests and aborts then exits the middleware chain and ends the request.

func Ping

func Ping(c *gin.Context)

func RequestId

func RequestId(trafficKey string) gin.HandlerFunc

RequestId 自动增加requestId, 设置 logger

func Secure

func Secure(c *gin.Context)

Secure is a middleware function that appends security and resource access headers.

func Sentinel

func Sentinel() gin.HandlerFunc

Sentinel 限流

func ServerInfo

func ServerInfo(c *gin.Context)

ServerInfo 获取系统信息 @Summary 系统信息 @Description 获取JSON @Tags 系统信息 @Success 200 {object} response.Response "{"code": 200, "data": [...]}" @Router /server-monitor [get] @Security Bearer

func SetDBOperLog

func SetDBOperLog(c *gin.Context, clientIP string, statusCode int, reqUri string, reqMethod string, latencyTime time.Duration, body string, result string, status int)

SetDBOperLog 写入操作日志表 fixme 该方法后续即将弃用

func TlsHandler

func TlsHandler() gin.HandlerFunc

func Trace

func Trace() gin.HandlerFunc

Trace 链路追踪

func WithContextDb

func WithContextDb(c *gin.Context)

Types

type File

type File struct {
	api.Api
}

func (File) UploadFile

func (e File) UploadFile(c *gin.Context)

UploadFile 上传图片 @Summary 上传图片 @Description 获取JSON @Tags 公共接口 @Accept multipart/form-data @Param type query string true "type" (1:单图,2:多图, 3:base64图片) @Param file formData file true "file" @Success 200 {string} string "{"code": 200, "message": "添加成功"}" @Success 200 {string} string "{"code": -1, "message": "添加失败"}" @Router /api/v1/public/uploadFile [post] @Security Bearer

type FileResponse

type FileResponse struct {
	Size     int64  `json:"size"`
	Path     string `json:"path"`
	FullPath string `json:"full_path"`
	Name     string `json:"name"`
	Type     string `json:"type"`
}

type UrlInfo

type UrlInfo struct {
	Url    string
	Method string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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