Skip to content

Commit

Permalink
Create a healthcheck endpoint (monit)
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciusandrade committed Oct 8, 2024
1 parent 30830e1 commit 65b5e40
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions controller/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,30 @@ async def search(
else:
result = '{"diaServerResponse":[' + result + ']}';
return JSONResponse(content=json.loads(result), headers={"Cache-Control": "no-cache"})


@app.get('/healthcheck')
async def healthcheck(
apikey: str = Header(...),
):
if apikey != API_TOKEN:
raise HTTPException(
status_code=HTTPStatus.UNAUTHORIZED,
detail='Invalid api key',
)

lang = 'en'
solr_server = set_solr_server("solr5/portal", None)
search_url = f"{solr_server}/select/"
query_map = {
'q': "malaria",
'rows': 1,
'facet': "false",
'wt': "json",
'json.nl': "arrarr"
}

result = await send_post_command(query_map, search_url)
result = decs.decode(result, lang)

return JSONResponse(content=json.loads(result), headers={"Cache-Control": "no-cache"})

0 comments on commit 65b5e40

Please sign in to comment.