Merge pull request #819 from r0fls/817

convert environment vars to int if digits
This commit is contained in:
Raphael Deem 2017-06-26 21:54:54 -07:00 committed by GitHub
commit 529f5822ee

View File

@ -201,4 +201,10 @@ class Config(dict):
for k, v in os.environ.items(): for k, v in os.environ.items():
if k.startswith(SANIC_PREFIX): if k.startswith(SANIC_PREFIX):
_, config_key = k.split(SANIC_PREFIX, 1) _, config_key = k.split(SANIC_PREFIX, 1)
self[config_key] = v try:
self[config_key] = int(v)
except ValueError:
try:
self[config_key] = float(v)
except ValueError:
self[config_key] = v