There are multiple global tables containing important data available while writing Lua code for the router.
selection_input
Contains arbitrary, custom fields fed into the router by clients, see API overview for details on how to inject data into this table.
Note that the selection_input
table is iterable.
Usage examples:
print(selection_input['some_value'])
-- Iterate over table
if selection_input then
for k, v in pairs(selection_input) do
print('here is '..'selection_input!')
print(k..'='..v)
end
else
print('selection_input is nil')
end
session_groups
Defines a mapping from session group name to boolean
, indicating whether
the session belongs to the session group or not.
Usage examples:
if session_groups.vod then print('vod') else print('not vod') end
if session_groups['vod'] then print('vod') else print('not vod') end
session_count
Provides counters of number of session types per session group. The table
uses the structure qoe_score.<session_type>.<session_group>
.
Usage examples:
print(session_count.instream.vod)
print(session_count.initial.vod)
qoe_score
Provides the quality of experience score per host per session group. The table
uses the structure qoe_score.<host>.<session_group>
.
Usage examples:
print(qoe_score.host1.vod)
print(qoe_score.host1.live)
request
Contains data related to the HTTP request between the client and the router.
request.method
string
'GET'
, 'POST'
request.body
string
or nil
'{"foo": "bar"}'
request.major_version
x
in HTTP/x.1
.integer
1
request.minor_version
x
in HTTP/1.x
.integer
1
request.protocol
string
'HTTP'
, 'HTTPS'
request.client_ip
string
'172.16.238.128'
request.path_with_query_params
string
'/mycontent/superman.m3u8?b=y&c=z&a=x'
request.path
string
'/mycontent/superman.m3u8'
request.query_params
string
'b=y&c=z&a=x'
request.filename
string
'superman.m3u8'
request.subnet
client_ip
.string
or nil
'all'
session
Contains data related to the current session.
session.client_ip
request.client_ip
. See documentation for
table request above.session.path_with_query_params
request.path_with_query_params
. See documentation
for table request above.session.path
request.path
. See documentation for
table request above.session.query_params
request.query_params
. See documentation for
table request above.session.filename
request.filename
. See documentation for
table request above.session.subnet
request.subnet
. See documentation for
table request above.session.host
string
or nil
'host1'
session.id
string
'8eb2c1bdc106-17d2ff-00000000'
session.session_type
string
'initial'
or 'instream'
. Identical to the value of the
Type
argument of the session translation function.session.is_managed
boolean
true
if Type
/session.session_type
is 'instream'
request_headers
Contains the headers from the request between the client and the router, keyed by name.
Usage example:
print(request_headers['User-Agent'])
request_query_params
Contains the query parameters from the request between the client and the router, keyed by name.
Usage example:
print(request_query_params.a)
session_query_params
Alias for metatable request_query_params
.
response
Contains data related to the outgoing response apart from the headers.
response.body
string
or nil
'{"foo": "bar"}'
response.code
integer
200
, 404
response.text
string
'OK'
, 'Not found'
response.major_version
x
in HTTP/x.1
.integer
1
response.minor_version
x
in HTTP/1.x
.integer
1
response.protocol
string
'HTTP'
, 'HTTPS'
response_headers
Contains the response headers keyed by name.
Usage example:
print(response_headers['User-Agent'])