ns_register - Register Tcl/ADP handlers
TABLE OF CONTENTS
SYNOPSIS
DESCRIPTION
COMMANDS
SEE ALSO
KEYWORDS
ns_register_adptag "christmas" "/christmas" xmas
proc xmas {string tagset} {
if { [ns_fmttime [ns_time] "%m/%d"] == "12/25" } {
return $string
}
}
|
<christmas>Merry Christmas to all, and to all a good night!</christmas> |
ns_register_adptag hello helloproc
proc helloproc { tags } {
return "Hello, [ns_set get $tags name]."
}
|
<hello name=Bob> |
/employees/*.tcl /accounts/*/out |
ns_share -init {set filters_installed 0} filters_installed
if {!$filters_installed} {
set filters_installed 1
ns_register_filter postauth GET /*.html ExpireSoon 3600
}
proc ExpireSoon {seconds why} {
ns_set update [ns_conn outputheaders] Expires [ns_httptime [expr $seconds + [ns_time]]]
}
|
ns_register_proc /foo/bar* |
ns_register_proc -noinherit GET /foo/bar Aproc ns_register_proc GET /foo/bar Bproc ns_register_proc GET /foo/bar/hmm Cproc |
ns_register_proc GET /noargs noargs
ns_register_proc GET /context context fnord
ns_register_proc GET /conncontext conncontext greeblev
proc noargs { } {
ns_returnnotice 200 "noargs"
};# noargs
proc context { context } {
ns_returnnotice 200 "context is $context"
};# context
proc conncontext { conn context } {
ns_returnnotice 200 "conncontext is $context"
};# conncontext
|
ns_register_proc GET /twoargs twoargs fnord
ns_register_proc GET /threeargs threeargs fnord fjord
proc twoargs { conn context { greeble bork } } {
# Do stuff...
}
proc threeargs { conn context {greeble bork } { hoover quark } {
# Do stuff...
}
|
ns_register_proxy GET http http_proxy_handler
proc http_proxy_handler { args } {
set port [ns_conn port]
if {$port == 0} {
set port 80
}
set url http://[ns_conn host]:$port[ns_conn url]?[ns_conn query]
ns_return 200 text/html [ns_httpget $url]]
}
|
/employees/*.tcl /accounts/*/out |