Profiling Nginx Processing Module Registration

Source: Internet
Author: User
Keywords Nginx
Tags callback function code configuration example function nginx processing registration

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.