摘要: "github.com/satori/go.uuid" uid, _ := uuid.NewV4()放在gin的context里玩耍 //c.Set("uuid", uid)//应用里面打日志//uid,_:= c.Get("uuid") 阅读全文
posted @ 2019-04-13 14:23 wujf 阅读(3349) 评论(0) 推荐(0) 编辑
摘要: 打window包直接go build一下,完事, 但是,打linux包出现如下错误 ..\github.com\mattn\go-isatty\isatty_linux.go:7:8: cannot find package "golang.org/x/sys/unix" in any of: 解决 阅读全文
posted @ 2019-04-13 11:24 wujf 阅读(1284) 评论(0) 推荐(0) 编辑
摘要: func Cors(c *gin.Context) { c.Header("Access-Control-Allow-Origin", "*") c.Header("Access-Control-Allow-Headers", "Content-Type,AccessToken,X-CSRF-Token, Authorization, Token") c.Header("... 阅读全文
posted @ 2019-04-13 10:52 wujf 阅读(470) 评论(0) 推荐(0) 编辑
摘要: 1、定义中间件 2、对要拦截的路由进行分组并引入中间件 3、测试 分别查看http://127.0.0.1:8088/api/ping和http://127.0.0.1:8088/ping,可以看出一个会输出“我是中间件”,一个不会输出 4、结论 什么权限、登陆、token之类的就这样起飞吧 阅读全文
posted @ 2019-04-13 10:47 wujf 阅读(1446) 评论(0) 推荐(0) 编辑
摘要: func wrapCtx(handler func(ctx *gin.Context)) gin.HandlerFunc { return func(c *gin.Context) { //获取请求的url log.Info("当前请求url:%s", c.Request.RequestURI) t 阅读全文
posted @ 2019-04-13 10:23 wujf 阅读(772) 评论(0) 推荐(0) 编辑