bus.go 340 B

1234567891011121314151617181920
  1. package middleware
  2. import (
  3. "kpt-tmr-group/dep"
  4. "github.com/gin-gonic/gin"
  5. )
  6. const KeyDep = "key:dep"
  7. func WithDependency(s *dep.HttpDependency) gin.HandlerFunc {
  8. return func(c *gin.Context) {
  9. c.Set(KeyDep, s)
  10. c.Next()
  11. }
  12. }
  13. func Dependency(c *gin.Context) *dep.HttpDependency {
  14. return c.MustGet(KeyDep).(*dep.HttpDependency)
  15. }