Skip to content

Commit

Permalink
Add debug to endpoint (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
cybermaggedon authored Dec 3, 2024
1 parent f24eed3 commit df23e29
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions trustgraph-flow/trustgraph/api/gateway/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ async def handle(self, request):

id = str(uuid.uuid4())

print(request.path, "...")

try:
ht = request.headers["Authorization"]
tokens = ht.split(" ", 2)
Expand All @@ -78,23 +80,31 @@ async def handle(self, request):

data = await request.json()

print(data)

q = await self.sub.subscribe(id)

await self.pub.send(
id,
self.to_request(data),
)
print("Request sent")

try:
resp = await asyncio.wait_for(q.get(), self.timeout)
except:
raise RuntimeError("Timeout waiting for response")

print("Response got")

if resp.error:
print("Error")
return web.json_response(
{ "error": resp.error.message }
)

print("Send response")

return web.json_response(
self.from_response(resp)
)
Expand Down

0 comments on commit df23e29

Please sign in to comment.