ADAPT::context_current

Description

This iRules command returns a handle for the current context. The current context is the context in which the event occurred from which the command was issued. In any command where a context is explicitly specified, any side also specified must be that of the current context or an error is raised. Best practice is not to specify a side when a context handle is specified. If no dynamic contexts have been created, the current context is the static context of the side to which the command applies (otherwise the static context serves only as a template for initializing dynamic contexts).

Syntax

ADAPT::context_current

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
    }
}