nchan
nchan copied to clipboard
nchan_subscriber_type isn't accessible by lua access block
I tried to access nchan_subscriber_type but value is null in access_by_lua_block stage. How it's possible to get the connection type ? I want to know it's HTTP or WEBSOCKET
location ~ "^/live/midrate/v1/rates/([A-Z]{3})([A-Z]{3})/(SPT|SN|ON|TN|W[1-3]|M[1-9][0-9]?|Y[2-5])/([D,N])/([O])/?$" {
# Default settings
default_type 'application/json;charset=UTF-8';
# nchan authorization settings
nchan_message_buffer_length 1;
nchan_message_timeout 96h;
nchan_subscriber;
nchan_channel_id "midrate-v1-$1$2-$3-$4-$5";
client_max_body_size 0;
nchan_subscribe_existing_channels_only on;
access_by_lua_block {
local res = ngx.location.capture("/auth/verify/authorization/v1/",{
args = {
key = "fiat.live.midrate.rates.".. ngx.var[3],
channels = ngx.var.nchan_subscriber_type,
instruments = { ngx.var[1], ngx.var[2] }
}
})
if res.status ~= ngx.HTTP_OK then
ngx.exit(res.status)
end
}
@slact