ad_register_filter (public)

 ad_register_filter [ -debug debug ] [ -priority priority ] \
    [ -critical critical ] [ -description description ] kind method \
    path proc [ arg ]

Defined in packages/acs-tcl/tcl/request-processor-procs.tcl

Registers a filter that gets called during page serving. The filter should return one of

  • filter_ok, meaning the page serving will continue;
  • filter_break meaning the rest of the filters of this type will not be called;
  • filter_return meaning the server will close the connection and end the request processing.

Switches:
-debug
(defaults to "f") (optional)
If debug is set to "t", all invocations of the filter will be ns_logged.
-priority
(defaults to "10000") (optional)
Priority is an integer; lower numbers indicate higher priority.
-critical
(defaults to "f") (optional)
If a filter is critical, page viewing will abort if a filter fails.
-description
(optional)
Parameters:
kind - Specify preauth, postauth or trace.
method - Use a method of "*" to register GET, POST, and HEAD filters.
path
proc
arg (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 http_auth::register_filter http_auth::register_filter (public) ad_register_filter ad_register_filter http_auth::register_filter->ad_register_filter packages/acs-core-docs/tcl/acs-core-docs-init.tcl packages/acs-core-docs/ tcl/acs-core-docs-init.tcl packages/acs-core-docs/tcl/acs-core-docs-init.tcl->ad_register_filter packages/acs-developer-support/tcl/acs-developer-support-init.tcl packages/acs-developer-support/ tcl/acs-developer-support-init.tcl packages/acs-developer-support/tcl/acs-developer-support-init.tcl->ad_register_filter packages/acs-tcl/tcl/admin-init.tcl packages/acs-tcl/ tcl/admin-init.tcl packages/acs-tcl/tcl/admin-init.tcl->ad_register_filter packages/acs-templating/tcl/template-init.tcl packages/acs-templating/ tcl/template-init.tcl packages/acs-templating/tcl/template-init.tcl->ad_register_filter apm_first_time_loading_p apm_first_time_loading_p (public) ad_register_filter->apm_first_time_loading_p

Testcases:
No testcase defined.
Source code:
    if {$method eq "*"} {
        # Shortcut to allow registering filter for all methods.
        foreach method { GET POST HEAD } {
           ad_register_filter -debug $debug -priority $priority -critical $critical $kind $method $path $proc $arg
        }
        return
    }

    if {$method ni { GET POST HEAD }} {
        error "Method passed to ad_register_filter must be one of GET, POST, or HEAD"
    }

    # Append the filter to the list. The list will be sorted according to priority
    # and the filters will be bulk-registered after package-initialization.
    # Also, the "Monitoring" package will be able to list the filters in this list.
    nsv_lappend rp_filters .  [list $priority $kind $method $path $proc $arg $debug $critical $description [info script]]

    # Register the filter immediately if the call is not from an *-init.tcl script.
    if { ![apm_first_time_loading_p] } {
        # Figure out how to invoke the filter, based on the number of arguments.
        if { [llength [info procs $proc]] == 0 } {
            # [info procs $proc] returns nothing when the procedure has been
            # registered by C code (e.g., ns_returnredirect). Assume that neither
            # "conn" nor "why" is present in this case.
            set arg_count 1
        } else {
            set arg_count [llength [info args $proc]]
        }

        set filter_index {}
        ns_register_filter $kind $method $path rp_invoke_filter [list $filter_index $debug $arg_count $proc $arg]
    }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: