12345678910111213141516171819 |
- package middleware
- import (
- "github.com/gin-gonic/gin"
- "kpt-event/dep"
- )
- const KeyDep = "key:dep"
- func WithDependency(s *dep.HttpDependency) gin.HandlerFunc {
- return func(c *gin.Context) {
- c.Set(KeyDep, s)
- c.Next()
- }
- }
- func Dependency(c *gin.Context) *dep.HttpDependency {
- return c.MustGet(KeyDep).(*dep.HttpDependency)
- }
|