annotate framework/env/request/for_each.lua @ 262:c3d539e33710
Replaced request.add_initializer(...) and request.add_variable(...) with request.for_each(...) and request.configure(...) which both execute the passed function once in any case when being called
 | author | jbe | 
 | date | Tue Mar 17 11:42:34 2015 +0100 (2015-03-17) | 
 | parents | framework/env/request/add_initializer.lua@9e4be058959d | 
 | children |  | 
 
 | rev | line source | 
| jbe@255 | 1 --[[-- | 
| jbe@262 | 2 request.for_each( | 
| jbe@262 | 3   func             -- function to be called on every request | 
| jbe@255 | 4 ) | 
| jbe@255 | 5 | 
| jbe@262 | 6 Registers a function to be called on every request and executes it once. This mechanism can be used for __init.lua files in the environment to perform a per-request initialization. See env/request/__init.lua for an example. | 
| jbe@255 | 7 | 
| jbe@255 | 8 --]]-- | 
| jbe@255 | 9 | 
| jbe@262 | 10 function request.for_each(func) | 
| jbe@255 | 11   local initializers = request._initializers | 
| jbe@255 | 12   initializers[#initializers+1] = func | 
| jbe@262 | 13   func() | 
| jbe@255 | 14 end |