2015-09-30 01:21:17 +00:00
|
|
|
package context
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/drone/drone/engine"
|
|
|
|
"github.com/drone/drone/remote"
|
2015-10-21 23:14:02 +00:00
|
|
|
"github.com/drone/drone/store"
|
2015-09-30 01:21:17 +00:00
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
2015-10-21 23:14:02 +00:00
|
|
|
func SetStore(s store.Store) gin.HandlerFunc {
|
2015-09-30 01:21:17 +00:00
|
|
|
return func(c *gin.Context) {
|
2015-10-21 23:14:02 +00:00
|
|
|
store.ToContext(c, s)
|
2015-09-30 01:21:17 +00:00
|
|
|
c.Next()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func SetRemote(remote remote.Remote) gin.HandlerFunc {
|
|
|
|
return func(c *gin.Context) {
|
|
|
|
c.Set("remote", remote)
|
|
|
|
c.Next()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func Remote(c *gin.Context) remote.Remote {
|
|
|
|
return c.MustGet("remote").(remote.Remote)
|
|
|
|
}
|
|
|
|
|
|
|
|
func SetEngine(engine engine.Engine) gin.HandlerFunc {
|
|
|
|
return func(c *gin.Context) {
|
|
|
|
c.Set("engine", engine)
|
|
|
|
c.Next()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func Engine(c *gin.Context) engine.Engine {
|
|
|
|
return c.MustGet("engine").(engine.Engine)
|
|
|
|
}
|