Skip to content

Commit

Permalink
patch(webhook): mod default response msg
Browse files Browse the repository at this point in the history
  • Loading branch information
piyoki committed Dec 16, 2023
1 parent 9ad6725 commit acf0a7e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/api/v1/endpoint/webhook.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import json
import os
from httpx import AsyncClient, HTTPError
from fastapi import APIRouter, Request, status
from fastapi import APIRouter, status
from fastapi.responses import JSONResponse
from fastapi.encoders import jsonable_encoder

Expand All @@ -14,14 +13,17 @@ async def forward(url):


@router.post("/webhook")
async def webhook(request: Request):
async def webhook():
try:
serialized_json = json.dumps(await request.json())
res = await forward(os.getenv("RELAY_SERVICE_ENDPOINT", ""))

if res.status_code == status.HTTP_200_OK:
return JSONResponse(
content=jsonable_encoder(json.loads(serialized_json)),
content=jsonable_encoder(
{
"message": "forwarded payload message to relay service successfully!"
}
),
status_code=status.HTTP_200_OK,
)
else:
Expand Down

0 comments on commit acf0a7e

Please sign in to comment.