mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-30 13:51:30 +00:00
21 lines
464 B
Go
21 lines
464 B
Go
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{})
|
|
}
|
|
|
|
// FromContext returns the Stream associated with this context.
|
|
func FromContext(c context.Context) Stream {
|
|
return c.Value(key).(Stream)
|
|
}
|
|
|
|
// ToContext adds the Stream to this context if it supports the
|
|
// Setter interface.
|
|
func ToContext(c Setter, s Stream) {
|
|
c.Set(key, s)
|
|
}
|