webmcp
diff framework/env/request/configure.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 | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/framework/env/request/configure.lua Tue Mar 17 11:42:34 2015 +0100 1.3 @@ -0,0 +1,16 @@ 1.4 +--[[-- 1.5 +request.configure( 1.6 + func -- function which is performing the configuration 1.7 +) 1.8 + 1.9 +Registers a function to be called on every request only if a request is not in progress yet. Executes the function once in any case. 1.10 + 1.11 +--]]-- 1.12 + 1.13 +function request.configure(func) 1.14 + if not request._in_progress then 1.15 + local initializers = request._initializers 1.16 + initializers[#initializers+1] = func 1.17 + end 1.18 + func() 1.19 +end