webmcp

diff 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
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/framework/env/request/for_each.lua	Tue Mar 17 11:42:34 2015 +0100
     1.3 @@ -0,0 +1,14 @@
     1.4 +--[[--
     1.5 +request.for_each(
     1.6 +  func             -- function to be called on every request
     1.7 +)
     1.8 +
     1.9 +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.
    1.10 +
    1.11 +--]]--
    1.12 +
    1.13 +function request.for_each(func)
    1.14 +  local initializers = request._initializers
    1.15 +  initializers[#initializers+1] = func
    1.16 +  func()
    1.17 +end

Impressum / About Us