bus.go 335 B

12345678910111213141516171819
  1. package middleware
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "kpt-event/dep"
  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. }