Parsing Variables to access them in a custom module
Vladimir Shebordaev
vshebordaev at mail.ru
Thu Jun 7 05:02:44 UTC 2012
2012/6/7 Prudhvi Krishna Surapaneni <me at prudhvi.net>:
> Hi All,
> I am trying to write a module that needs to consume the regex matched
> variables like $1 and $2 and pass them as values to the module.
>
> Here is what i am trying to do
>
> /* -- CONFIG -- */
>
> location ~ /foo/([a-zA-Z0-9]+)/bar/([0-9]+) {
> my_module;
> my_module_first $1;
> my_module_second $2;
> }
>
> /* -- CONFIG -- */
>
> Inside my module i have defined them as follows.
>
> /* -- CODE -- */
>
> typedef stuct {
> ngx_str_t my_module_first;
> ngx_str_t my_module_second;
> } ngx_http_my_module_loc_conf_t
>
> /* -- CODE -- */
>
> When trying to access the values from those variables i get the
> value $1 and $2 instead of the substitution. What am i missing?.
>
> Are these variables only availble for the rewrite module?.
Not particularly. But you should use the script engine to get captures
evaluated at run-time. See, e.g. proxy module for an example.
>
> Thanks,
> Prudhvi Krishna Surapaneni.
>
More information about the nginx-devel
mailing list