feat: fastapi app mit lifespan, webhook handler und /health
This commit is contained in:
20
app/webhook/handler.py
Normal file
20
app/webhook/handler.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from fastapi import APIRouter, BackgroundTasks, Header, status
|
||||
|
||||
from app.config import get_settings
|
||||
from app.ingest.pipeline import process_file
|
||||
from app.webhook.auth import verify_secret
|
||||
from app.webhook.models import NextcloudEvent
|
||||
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/webhook", status_code=status.HTTP_202_ACCEPTED)
|
||||
async def webhook(
|
||||
event: NextcloudEvent,
|
||||
background: BackgroundTasks,
|
||||
x_webhook_secret: str | None = Header(default=None),
|
||||
):
|
||||
verify_secret(x_webhook_secret, get_settings().webhook_secret)
|
||||
background.add_task(process_file, event.file_path, event.event_type)
|
||||
return {"status": "accepted"}
|
||||
Reference in New Issue
Block a user