mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-30 08:06:52 +02:00
22 lines
449 B
Go
22 lines
449 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 Mux associated with this context.
|
|
func FromContext(c context.Context) Mux {
|
|
return c.Value(key).(Mux)
|
|
}
|
|
|
|
// ToContext adds the Mux to this context if it supports
|
|
// the Setter interface.
|
|
func ToContext(c Setter, m Mux) {
|
|
c.Set(key, m)
|
|
}
|