1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-06-30 22:13:45 +02:00
Files
woodpecker/stream/context.go

22 lines
464 B
Go
Raw Normal View History

2016-04-12 17:27:24 -07:00
package stream
import "golang.org/x/net/context"
const key = "stream"
// Setter defines a context that enables setting values.
type Setter interface {
Set(string, interface{})
}
2016-04-22 17:35:32 -07:00
// FromContext returns the Stream associated with this context.
func FromContext(c context.Context) Stream {
return c.Value(key).(Stream)
2016-04-12 17:27:24 -07:00
}
2016-04-22 17:35:32 -07:00
// ToContext adds the Stream to this context if it supports the
// Setter interface.
func ToContext(c Setter, s Stream) {
c.Set(key, s)
2016-04-12 17:27:24 -07:00
}