add health endpoint

This commit is contained in:
histausse 2021-10-07 17:24:13 +02:00
parent d89c0a2626
commit f8258117f4
Signed by: histausse
GPG key ID: 67486F107F62E9E9

View file

@ -24,13 +24,19 @@ async def run_webhook(
Run the webhook endpoint and put the alerts in the queue. Run the webhook endpoint and put the alerts in the queue.
""" """
async def handler(request:aiohttp.web_request.Request): async def handler(request:aiohttp.web_request.Request)->aiohttp.web.Response:
alert = await request.json() alert = await request.json()
await alert_queue.put(alert) await alert_queue.put(alert)
return aiohttp.web.Response() return aiohttp.web.Response()
async def health(request:aiohttp.web_request.Request)->aiohttp.web.Response:
return aiohttp.web.Response(text="OK")
app = aiohttp.web.Application() app = aiohttp.web.Application()
app.add_routes([aiohttp.web.post(config.endpoint, handler)]) app.add_routes([
aiohttp.web.post(config.endpoint, handler),
aiohttp.web.get("/health", health)
])
runner = aiohttp.web.AppRunner(app) runner = aiohttp.web.AppRunner(app)
await runner.setup() await runner.setup()
ssl_context = None ssl_context = None