是否有一种方法可以在Connection
中获取(或从session[:_csrf_token]
传递)请求数据(实际上,我需要Channel
,不要问为什么)?例如:
class MeetingChannel < ApplicationCable::Channel
def subscribed
session[:_csrf_token]
end
end
目前,我只能在csrf_token
中获得Connection
:
module ApplicationCable
class Connection < actionCable::Connection::Base
def connect
puts "**********************************************************"
puts "CSRF token: #{request.session[:_csrf_token]}"
puts "**********************************************************"
end
end
end
输出(连接时):
**********************************************************
CSRF token: u33bsVI7HnF2bqWRfkriQUlLzIUpccdVovgRTAkoGKM=
**********************************************************