Skip to content

Commit

Permalink
add health check
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixTJDietrich committed Aug 1, 2024
1 parent e00cc04 commit a478fd5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion server/webhook-distributor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ To register a destination, send a POST request to `/register` with the following

### Send a webhook

To send a webhook, send a POST request to `/webhook`. The webhook will be forwarded to all registered destinations.
To send a webhook, send a POST request to `/`. The webhook will be forwarded to all registered destinations.
20 changes: 18 additions & 2 deletions server/webhook-distributor/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Set
from fastapi import FastAPI, Request
from fastapi import FastAPI, Request, status
from pydantic import BaseModel
import httpx

Expand All @@ -21,7 +21,7 @@ def register_destination(destination: Destination):
return { "message": "Destination registered successfully" }


@app.post("/webhook")
@app.post("/")
async def send_webhook(request: Request):
payload = await request.json()
failed_destinations = []
Expand All @@ -41,3 +41,19 @@ async def send_webhook(request: Request):
"failed": len(failed_destinations),
"success_destinations": len(destinations),
}


class HealthCheck(BaseModel):
status: str = "OK"


@app.get(
"/health",
tags=["healthcheck"],
summary="Perform a Health Check",
response_description="Return HTTP Status Code 200 (OK)",
status_code=status.HTTP_200_OK,
response_model=HealthCheck,
)
def get_health() -> HealthCheck:
return HealthCheck(status="OK")

0 comments on commit a478fd5

Please sign in to comment.