jbe@255: --[[-- jbe@255: request.add_variable( jbe@255: tbl, -- table where the variable is stored jbe@255: key, -- name of variable (key within the table) jbe@255: value -- optional value for initialization jbe@255: ) jbe@255: jbe@255: Marks a field of a table to be re-initialized for every request. If this variable (i.e. the field of the table) is modified before the first requst is being handled (e.g. during configuration or pre-/post-fork initializers), then the modified value will be used for re-initialization on every request. See env/request/__init.lua for an example. jbe@255: jbe@255: --]]-- jbe@255: jbe@255: function request.add_variable(tbl, key, value) jbe@255: local initialized_value jbe@255: tbl[key] = value jbe@255: request.add_initializer(function(first) jbe@255: if first then jbe@255: initialized_value = tbl[key] jbe@255: else jbe@255: tbl[key] = initialized_value jbe@255: end jbe@255: end) jbe@255: end