NaviServer - programmable web server
4.99  5.0

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

ns_locationproc(n) 4.99.30 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

script Tcl script which result will be used to return the location string.

EXAMPLES

 namespace eval nstest {
    ns_locationproc ::nstest::location
    ad_proc ::nstest::location {args} {
        set location [ns_conn protocol]://[ns_set iget [ns_conn headers] host]
        ns_log notice "LOCATION-PROC args <$args> - location <$location>"
        return $location
    }
    ns_log notice "SOURCING location-procs.tcl <[ns_info server]>"
 }

See Also

ns_conn, ns_serverrootproc

Keywords

global built-in, hosting, redirect, virtual