github.com/bingoohuang/gg@v0.0.0-20240325092523-45da7dee9335/pkg/ginx/hlog/ctx.go (about) 1 package hlog 2 3 import ( 4 "github.com/gin-gonic/gin" 5 ) 6 7 // Attrs carries map. It implements value for that key and 8 // delegates all other calls to the embedded Context. 9 type Attrs map[string]interface{} 10 11 // PutAttr put an attribute into the Attributes in the context. 12 func PutAttr(c *gin.Context, key string, value interface{}) { 13 c.Set(key, value) 14 } 15 16 // PutAttrMap put an attribute map into the Attributes in the context. 17 func PutAttrMap(c *gin.Context, attrs map[string]interface{}) { 18 for k, v := range attrs { 19 c.Set(k, v) 20 } 21 }