-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[configuration] split loaders into own modules
so they can evolve independently and start form their api
- Loading branch information
Showing
8 changed files
with
265 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
local getenv = os.getenv | ||
local len = string.len | ||
local tostring = tostring | ||
local open = open | ||
local assert = assert | ||
|
||
local _M = { | ||
_VERSION = '0.1' | ||
} | ||
|
||
local function read(path) | ||
if not path or len(tostring(path)) == 0 then | ||
return nil, 'missing path' | ||
end | ||
|
||
ngx.log(ngx.INFO, 'configuration loading file ' .. path) | ||
return assert(open(path)):read('*a') | ||
end | ||
|
||
function _M.call(path) | ||
local file = path or getenv('THREESCALE_CONFIG_FILE') | ||
|
||
return read(file) | ||
end | ||
|
||
return _M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
local _M = { | ||
_VERSION = '0.1', | ||
config = false | ||
} | ||
|
||
function _M.call() | ||
return _M.config | ||
end | ||
|
||
function _M.save(config) | ||
_M.config = config | ||
end | ||
|
||
return _M |
Oops, something went wrong.