LyricTian / gin-admin

A lightweight, flexible, elegant and full-featured RBAC scaffolding based on GIN + GORM 2.0 + Casbin 2.0 + Wire DI.
http://101.42.232.163:8040
Apache License 2.0
2.57k stars 518 forks source link

萌新请教个context问题 #117

Closed cpj555 closed 2 years ago

cpj555 commented 2 years ago

我看代码中都是用 gin.Context.Request.Context保存上下文的,为啥不用gin.Context直接保存上下文呢,新手不太了解

qinxuechao commented 2 years ago

Gin Context本身就是自己封装的一层,不是golang里面原始的context。看一下https://github.com/gin-gonic/gin/blob/master/context.go#L48

cpj555 commented 2 years ago

我是想请教两者使用上有本质的差别么 我之前自己写的 trace_id和user用户态都是直接存在*gin.Context里的 而作者的代码 上下文是存在 gin.Context.Request.Context里的

Conight commented 2 years ago

有些包中不用再去引入 gin

cpj555 commented 2 years ago

大概了解意思了 感谢