NaviServer - programmable web server
4.99  5.0

[ Main Table Of Contents | Table Of Contents | Keyword Index ]

ns_locationproc(n) 5.0.0a naviserver "NaviServer Built-in Commands"

Name

ns_locationproc - Register custom location handler

Table Of Contents

Synopsis

Description

This command installs a custom script which will return location string for the current connection, as returned by ns_conn location. Usually, a location looks like http://localhost/. ns_locationproc registers the handler for the current server. Therefore, the command cannot be used in the configuration script (no current server, defining the setup of all servers), but in the module files.

COMMANDS

ns_locationproc script ?arg ...?

The Tcl script will be called returning the location string, containing the URL scheme (protocol) and the authority (hostname and port) in the syntax as specified by the HTTP RFCs.

When the optional arguments are provided, these are added to the command script to be executed. Therefore, two invocation styles are supported: either providing a script, or a command with additional arguments.

EXAMPLES

 namespace eval nstest {
    ns_locationproc ::nstest::location
    ad_proc ::nstest::location {args} {
        set location [ns_conn protocol]://[ns_set get -nocase [ns_conn headers] host]
        ns_log notice "LOCATION-PROC args <$args> - location <$location>"
        return $location
    }
 }

See Also

ns_conn, ns_serverrootproc

Keywords

global built-in, redirect, virtual host