mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-30 10:56:23 +02:00
Add debug to endpoint (#188)
This commit is contained in:
parent
f24eed3023
commit
df23e29971
1 changed files with 10 additions and 0 deletions
|
|
@ -62,6 +62,8 @@ class ServiceEndpoint:
|
|||
|
||||
id = str(uuid.uuid4())
|
||||
|
||||
print(request.path, "...")
|
||||
|
||||
try:
|
||||
ht = request.headers["Authorization"]
|
||||
tokens = ht.split(" ", 2)
|
||||
|
|
@ -78,23 +80,31 @@ class ServiceEndpoint:
|
|||
|
||||
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)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue