lua-resty-env
Cache for os.getenv calls
$ opm get 3scale/lua-resty-env
Name
lua-resty-env - Lua cache for calls to os.getenv
.
Status
This library is considered production ready.
Description
This Lua library is a cache for calls to os.getenv
.
This library acts as a mediator between other libraries and the environment variables. Variables can not only be get but also set.
Synopsis
env SOME_VARIABLE;
http {
server {
location /test {
content_by_lua_block {
local resty_env = require 'resty.env'
ngx.say("SOME_VARIABLE: ", resty_env.get('SOME_VARIABLE'))
}
}
}
Methods
All the methods are expected to be called on the module without self.
get
syntax: val = env.get(name)
Returns environment value from the cache or uses os.getenv
to get it.
set
syntax: prev = env.set(name, value)
Sets the the value
to the cache and returns the previous value in the cache.
enabled
syntax: ok = env.enabled(name)
Returns true if the environment variable has truthy value (1
, true
), false (0
, false
) or nil
.
reset
syntax: env = env.reset()
Resets the internal cache.
Installation
If you are using the OpenResty bundle (http://openresty.org ), then you can use opm to install this package.
opm get 3scale/lua-resty-env
Bugs and Patches
Please report bugs or submit patches by
creating a ticket on the GitHub Issue Tracker,
Author
Michal "mikz" Cichra <mcichra@redhat.com>, Red Hat Inc.
Copyright and License
This module is licensed under the Apache License Version 2.0.
Copyright (C) 2016-2017, Red Hat Inc.
All rights reserved.
See LICENSE for the full license.
See Also
the APIcast API Gateway: https://github.com/3scale/apicast/#readme
Authors
Michal Cichra (mikz)
License
apache2
Dependencies
ngx_http_lua
Versions
-
3scale/lua-resty-env 0.3.0Cache for os.getenv calls 2017-07-04 13:50:28
-
Cache for os.getenv calls 2017-04-06 11:55:29