NaviServer Programmable Web Server

ns_register_cgi(n)

nscgi Built-in Commands – 5.0.0b1


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

Name

ns_register_cgi - Register CGI handlers

Table Of Contents

Synopsis

Description

This document describes how to register a CGI handler programmatically.

COMMANDS

ns_register_cgi ?-constraints constraints? ?-noinherit? ?-matchsegments? ?-path value? ?--? method url

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).

EXAMPLE

 # 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 ...

See Also

ns_register, nscgi

Keywords

CGI, callback, context constraints, fastpath, handler, nscgi, request, urlspace