nscgi Built-in Commands – 5.0.0b1
ns_register_cgi - Register CGI handlers
This document describes how to register a CGI handler programmatically.
The command registers the CGI handler for requests matching method and URL to be handled as CGI programs. The specified url can contain a match pattern, which is handled by the NaviServer urlspace (like in ns_register_proc). The match will always be a match on the last URL segment, unless -matchsegments is specified.
The option -constraints allows you to specify additional context constraints to specify, when this handler should be invoked (for details see Context Constraints).
If -noinherit is specified, the request URL must match the directory of the registered URL.
If -matchsegments is specified, the pattern will be matched with all segments of the request URL.
The -path specifies the source location for the files in case the request URL matches the register URL. The provided source location is registered via ns_register_fasturl2file such that fastpath can resolve the request path against this source location.
Handlers registered with ns_register_cgi can be unregistered via ns_unregister_op. In case the -path was specified, it can be unregistered with ns_unregister_url2file.
The mapping via ns_register_cgi is the programmatical counterpart to define the mapping via the configuration file in the section "ns/server/$servername/module/nscgi" (see nscgi).
# Bind CGI handler for /admin/panel only when the incoming request # has the specified request header field. ns_register_cgi -constraints {X-User *admin*} GET /admin/Panel ...