Пример #1
0
// GetRegistry returns a registry instance for the current request.
func GetRegistry(r *http.Request) *Registry {
	registry := context.Get(r, registryKey)
	if registry != nil {
		return registry.(*Registry)
	}
	newRegistry := &Registry{
		request:  r,
		sessions: make(map[string]sessionInfo),
	}
	context.Set(r, registryKey, newRegistry)
	return newRegistry
}
Пример #2
0
func setCurrentRoute(r *http.Request, val interface{}) {
	if val != nil {
		context.Set(r, routeKey, val)
	}
}
Пример #3
0
func setVars(r *http.Request, val interface{}) {
	if val != nil {
		context.Set(r, varsKey, val)
	}
}