【问题标题】:Revel session clustering with redis使用 Redis 进行 Revel 会话集群
【发布时间】:2018-10-05 17:12:25
【问题描述】:

在水晶#kemal 中,我有 before_all 方法,它将成为请求的网关(以及用于身份验证检查)

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

revel 有 before_all 这样的方法吗,我可以像 kemal 那样做吗?

【问题讨论】:

    标签: go redis revel


    【解决方案1】:

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

    func (c App) SessionProcess() revel.Result {
        # do action
        return nil
    }
    
    func init() {
        revel.InterceptMethod(App.SessionProcess, revel.BEFORE)
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-17
      • 1970-01-01
      • 2017-01-23
      • 2012-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多