First
This commit is contained in:
35
server/context.go
Normal file
35
server/context.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"code.google.com/p/go.net/context"
|
||||
)
|
||||
|
||||
type ctx struct{}
|
||||
|
||||
func (ctx *ctx) Deadline() (deadline time.Time, ok bool) {
|
||||
return time.Time{}, false
|
||||
}
|
||||
|
||||
func (ctx *ctx) Done() <-chan struct{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ctx *ctx) Err() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ctx *ctx) Value(key interface{}) interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func newContext(parent context.Context, s *serverContext) context.Context {
|
||||
return context.WithValue(parent, "serverContext", s)
|
||||
}
|
||||
|
||||
// return server.Context
|
||||
func NewContext(ctx context.Context) (Context, bool) {
|
||||
c, ok := ctx.Value("serverContext").(*serverContext)
|
||||
return c, ok
|
||||
}
|
||||
Reference in New Issue
Block a user