implemented '/-/config' endpoint to list runtime environment variables

This commit is contained in:
Oscar Krause 2023-01-02 19:14:25 +01:00
parent 34662e6612
commit 2e950ca6f4
3 changed files with 28 additions and 2 deletions

View File

@ -25,7 +25,11 @@ Status endpoint, used for *healthcheck*. Shows also current version and commit h
### `GET /-/health` ### `GET /-/health`
Status endpoint, used for *healthcheck*. Shows also current version and commit hash. Status endpoint, used for *healthcheck*.
### `GET /-/config`
Shows current runtime environment variables and their values.
### `GET /-/readme` ### `GET /-/readme`

View File

@ -81,7 +81,24 @@ async def _index():
@app.get('/-/health', summary='* Health') @app.get('/-/health', summary='* Health')
async def _health(request: Request): async def _health(request: Request):
return JSONResponse({'status': 'up', 'version': VERSION, 'commit': COMMIT, 'debug': DEBUG}) return JSONResponse({'status': 'up'})
@app.get('/-/config', summary='* Config', description='returns environment variables.')
async def _config():
return JSONResponse({
'VERSION': VERSION,
'COMMIT': COMMIT,
'DEBUG': DEBUG,
'DLS_URL': DLS_URL,
'DLS_PORT': DLS_PORT,
'SITE_KEY_XID': SITE_KEY_XID,
'INSTANCE_REF': INSTANCE_REF,
'TOKEN_EXPIRE_DELTA': TOKEN_EXPIRE_DELTA,
'LEASE_EXPIRE_DELTA': LEASE_EXPIRE_DELTA,
'LEASE_RENEWAL_PERIOD': LEASE_RENEWAL_PERIOD,
'CORS_ORIGINS': CORS_ORIGINS,
})
@app.get('/-/readme', summary='* Readme') @app.get('/-/readme', summary='* Readme')

View File

@ -56,6 +56,11 @@ def test_health():
assert response.json()['status'] == 'up' assert response.json()['status'] == 'up'
def test_config():
response = client.get('/-/')
assert response.status_code == 200
def test_readme(): def test_readme():
response = client.get('/-/readme') response = client.get('/-/readme')
assert response.status_code == 200 assert response.status_code == 200