package session import "context" type contextKeyType struct{ name string } func (ck *contextKeyType) String() string { return ck.name } var contextKey = &contextKeyType{name: "session context key"} // FromContext gets a session fron the context. func FromContext(ctx context.Context) *Session { return ctx.Value(contextKey).(*Session) } func contextWithSession(parent context.Context, session *Session) context.Context { return context.WithValue(parent, contextKey, session) }