db.go 279 B

123456789101112
  1. package middleware
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "gogs.baozhida.cn/zoie/OAuth-core/sdk"
  5. "gogs.baozhida.cn/zoie/OAuth-core/sdk/config"
  6. )
  7. func WithContextDb(c *gin.Context) {
  8. c.Set("db", sdk.Runtime.GetDbByKey(config.ApplicationConfig.Host).WithContext(c))
  9. c.Next()
  10. }