使用Redis的Revel会话聚类

时间:2018-10-05 17:12:26

标签: go redis revel

在crystal#kemal中,我有before_all方法,它将作为请求的网关(并用于auth检查)

before_all do |env|
  # go to /login if user doesn't have cookie (set cookie on login)
  if env.request.path != "/login"
    if env.request.cookies.has_key?("guid") == false
      env.redirect "/login"
    else
      user_guid = env.request.cookies["guid"].value
      # if in redis is logged, but not in the app
      if is_logged_in(user_guid)
        if !is_logged(env)
          app_sess_set(env, user_guid)
        end
      else
        env.redirect "/login"
      end
    end
  end
end

陶醉有像before_all这样的方法吗,我可以像凯末尔那样吗?

1 个答案:

答案 0 :(得分:0)

http://revel.github.io/manual/interceptors.html

variable_manager.add_group_vars_file(groupvarfile, loader)