lua-resty-env - Lua cache for calls to os.getenv
.
- Name
- Status
- Description
- Synopsis
- Methods
- Installation
- TODO
- Community
- Bugs and Patches
- Author
- Copyright and License
- See Also
This library is considered production ready.
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.
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'))
}
}
}
All the methods are expected to be called on the module without self.
syntax: val = env.get(name)
Returns environment value from the cache or uses os.getenv
to get it.
syntax: prev = env.set(name, value)
Sets the the value
to the cache and returns the previous value in the cache.
syntax: val = env.value(name)
Same as get
, but returns nil for envs whose value is an empty string.
syntax: table = env.list()
Returns a table with all environment variables. Names are keys and values are values.
syntax: ok = env.enabled(name)
Returns true if the environment variable has truthy value (1
, true
), false (0
, false
) or nil
.
syntax: env = env.reset()
Resets the internal cache.
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
Please report bugs or submit patches by
- creating a ticket on the GitHub Issue Tracker,
Michal "mikz" Cichra [email protected], Red Hat Inc.
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.
- the APIcast API Gateway: https://github.com/3scale/apicast/#readme