gluon/scripts/domain_config.lua
lemoer 0834985205 check_site_lib: merge site & domain and provide restricting feature
- provide in_domain() and in_site() functions to restrict usage:

need_string('foo.bar') -- allowed in both domain and site config
need_string(in_site('foo.bar')) -- only allowed in site config
need_string(in_domain('foo.bar')) -- only allowed in domain config

- need_* merge the domain and site configs while prefering the domain
  values
2017-12-28 19:59:38 +01:00

14 lines
438 B
Lua

local function load_domain(domain_code)
local config = os.getenv('GLUON_SITEDIR')
local function loader()
coroutine.yield('return ')
coroutine.yield(io.open(config .. '/domains/' .. domain_code .. '.conf'):read('*a'))
end
-- setfenv doesn't work with Lua 5.2 anymore, but we're using 5.1
return setfenv(assert(load(coroutine.wrap(loader), 'domains/' .. domain_code .. '.conf')), {})()
end
return load_domain