The processing module is registered by adding code to the callback function in the directive. For example, my circle GIF ngx_command_t structure looks like this:
{ngx_string ("circle_gif"),
Ngx_http_loc_conf| Ngx_conf_noargs,
Ngx_http_circle_gif,
0,
0,
NULL}
The callback function is the third member, in this case the Ngx_http_circle_gif function. Notice this callback function parameter is the configuration structure body (ngx_conf_t, save user's parameter), the related ngx_command_t structure body, and a configuration structure body that points to the module customization. In my circle GIF module, this function looks like this:
Static char *
Ngx_http_circle_gif (ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
ngx_http_core_loc_conf_t *CLCF;
CLCF = ngx_http_conf_get_module_loc_conf (cf, Ngx_http_core_module);
Clcf->handler = Ngx_http_circle_gif_handler;
return NGX_CONF_OK;
}
There are two steps in the function to get the "core" structure of the location configuration, and then assign a handler function to it. is not very simple, hehe.