2015-01-11 08:52:39 +02:00
|
|
|
package authboss
|
|
|
|
|
|
|
|
// Context provides context for module operations and callbacks. One obvious
|
|
|
|
// need for context is a request's session store. It is not safe for use by
|
|
|
|
// multiple goroutines.
|
|
|
|
type Context struct {
|
2015-01-13 00:02:07 +02:00
|
|
|
SessionStorer ClientStorer
|
|
|
|
CookieStorer ClientStorer
|
|
|
|
User Attributes
|
2015-01-11 08:52:39 +02:00
|
|
|
|
|
|
|
keyValues map[string]interface{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewContext() *Context {
|
|
|
|
return &Context{
|
|
|
|
keyValues: make(map[string]interface{}),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-13 00:02:07 +02:00
|
|
|
// Put an arbitrary key-value into the context.
|
2015-01-11 08:52:39 +02:00
|
|
|
func (c *Context) Put(key string, thing interface{}) {
|
|
|
|
c.keyValues[key] = thing
|
|
|
|
}
|
|
|
|
|
2015-01-13 00:02:07 +02:00
|
|
|
// Get an arbitrary key-value from the context.
|
2015-01-11 08:52:39 +02:00
|
|
|
func (c *Context) Get(key string) (thing interface{}, ok bool) {
|
|
|
|
thing, ok = c.keyValues[key]
|
|
|
|
return thing, ok
|
|
|
|
}
|