Forum: NGINX Where to store global settings in filter

D4b6aa162cd8ac71e8db60dea1ec2904?d=identicon&s=25 Jerry OELoo (Guest)
on 2014-08-25 04:55
(Received via mailing list)
Hi All:
I have some settings in a json file (not in nginx.conf file),
Currently, in my module filter function, I will open file, read file,
close file every time filter function is called.
I think this is not so good, so I think it's better call a function
just one time, and save the setting in a global variable, but I do not
where is a proper position in Nginx module, Thanks!

--
Rejoice,I Desire!
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2014-08-25 15:21
(Received via mailing list)
Hello!

On Mon, Aug 25, 2014 at 10:55:06AM +0800, Jerry OELoo wrote:

> Hi All:
> I have some settings in a json file (not in nginx.conf file),
> Currently, in my module filter function, I will open file, read file,
> close file every time filter function is called.
> I think this is not so good, so I think it's better call a function
> just one time, and save the setting in a global variable, but I do not
> where is a proper position in Nginx module, Thanks!

It may be a good idea to read the json file while parsing
configuration.  Such things are usually done either when
processing a directive which specifies a file to use, or in a
configuration merge callback.

E.g., XSLT filter loads stylesheets specified in the
ngx_http_xslt_stylesheet() function, which is called to handle the
"xslt_stylesheet" directive.  See
src/http/modules/ngx_http_xslt_filter_module.c for details.

--
Maxim Dounin
http://nginx.org/
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.