Session Translation Function
Specifies the body of a Lua function that inspects a newly created session and may override its suggested type from “initial” to “instream” or vice versa.
Returns nil
when the session type is to remain unchanged, or Session(t)
where t
is a table with a single field:
Type
- Description: New type of the session.
- Type:
string
- Example:
'instream'
,'initial'
Example of a session_translation_function
body that unconditionally makes
all sessions 'instream'
:
-- Statements go here
print('Modifying session type')
return Session({['Type'] = 'instream'})
Arguments
The following (iterable) arguments are passed to the function:
Type
- Description: The suggested type of the session.
- Type:
string
- Example:
'instream'
,'initial'
Example usage:
-- Flip session type
local newType = 'initial'
if Type == 'initial' then
newType = 'instream'
end
print('Changing session type from ' .. Type .. ' to ' .. newType)
return Session({['Type'] = newType})
Global metatables
In addition to the arguments above, the following (non-iterable) global metatables will be populated with fields that may be retrieved by the response translation function.
Metatable request
See documentation for request_translation_function. If the
request translation function has modified the incoming request, the request
metatable will contain those changes.
Metatable request_query_params
See documentation for request_translation_function. If the request translation function has modified the incoming request, the
request_query_params
metatable will contain those changes.
Metatable session_query_params
Alias for metatable request_query_params
.
Metatable request_headers
See documentation for request_translation_function. If
the request translation function has modified the incoming request, the
request_headers
metatable will contain those changes.
Metatable session
session.client_ip
- Description: Alias for
request.client_ip
. See documentation for request_translation_function.
- Description: Alias for
session.path_with_query_params
- Description: Alias for
request.path_with_query_params
. See documentation for request_translation_function.
- Description: Alias for
session.path
- Description: Alias for
request.path
. See documentation for request_translation_function.
- Description: Alias for
session.query_params
- Description: Alias for
request.query_params
. See documentation for request_translation_function.
- Description: Alias for
session.filename
- Description: Alias for
request.filename
. See documentation for request_translation_function.
- Description: Alias for
session.subnet
- Description: Alias for
request.subnet
. See documentation for request_translation_function.
- Description: Alias for
session.host
- Description: ID of the currently selected host for the session.
- Type:
string
ornil
- Example:
'host1'
session.id
- Description: ID of the session.
- Type:
string
- Example:
'8eb2c1bdc106-17d2ff-00000000'
session.session_type
- Description: Type of the session.
- Type:
string
- Example:
'initial'
or'instream'
. Identical to the value of theType
argument of the session translation function.
session.is_managed
- Description: Identifies managed sessions.
- Type:
boolean
- Example:
true
ifType
/session.session_type
is'instream'
Metatable session_groups
Defines a mapping from session group name to boolean
, indicating whether
the session belongs to the session group or not.
Example usage:
if session_groups.vod then print('vod') else print('not vod') end
or
if session_groups['vod'] then print('vod') else print('not vod') end
Global tables
In addition to the (non-iterable) metatables and (iterable) arguments above, the following global iterable tables are available from all Lua functions:
Table selection_input
See documentation for See documentation for request_translation_function.
Values in the selection_input
metatable will remain unchanged since a prior
call to a request_translation_function
.