while in crystal#kemal, i have before_all method that will be a gateway of request (and for auth check)
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
is revel has method like before_all
, and can i do like kemal do ?
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)
}