示例#1
0
文件: sessions.go 项目: hoang-nc/gf
// 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
文件: helpers.go 项目: goframework/gf
// envError stores a CSRF error in the request context.
func EnvError(r *http.Request, err error) {
	context.Set(r, ErrorKey, err)
}