ADAPT::context_create¶
Description¶
This iRules command creates a new dynamic context on the specified or
current side. Can only be called from a client side event (server side
context creation is not currently supported, so server side contexts
must be created from the client side). The name should uniquely
identify a dynamic context within a virtual server and is useful for
debug logging. The sequential position of the new context in the chain
cannot currently be specified: a client side (request) context is
inserted last in the chain (executed after all previously created
contexts); a server side (response) is inserted first in the chain.
The iRule should call ADAPT::context_create in the appropriate order
to achieve the desired execution order (which on the server side is
the reverse of the order of creation).
Examples¶
when HTTP_REQUEST {
log local0. “Event HTTP_REQUEST"
# Disable the static configs (templates for dynamic)
ADAPT::enable request false
ADAPT::enable response false
# Create the first dynamic context on the clientside and configure it.
set req_ctx1 [ADAPT::context_create req_ctx1]
ADAPT::select $req_ctx1 /Common/ivs-req1-example
ADAPT::enable $req_ctx1 true
# Create the first dynamic context on the serverside and configure it (pending).
set rsp_ctx1 [ADAPT::context_create response rsp_ctx1]
ADAPT::select $rsp_ctx1 /Common/ivs-rsp1-example
ADAPT::enable $rsp_ctx1 true
}
when ADAPT_REQUEST_RESULT {
set ctx [ADAPT::context_current]
set ctx_name [ADAPT::context_name $ctx]
log local0. "Event ADAPT_REQUEST_RESULT in context $ctx_name"
if {$ctx == $req_ctx1} {
# Create the second dynamic context on the clientside and configure it.
set req_ctx2 [ADAPT::context_create req_ctx2]
ADAPT::select $req_ctx2 /Common/ivs-req2-example
ADAPT::enable $req_ctx2 true
# Create the second dynamic context on the serverside and configure it.
set rsp_ctx2 [ADAPT::context_create response demo_rsp_ctx2]
ADAPT::select $rsp_ctx2 /Common/ivs-rsp2-example
ADAPT::enable $rsp_ctx2 true
}
}