Add debug to endpoint (#188)

This commit is contained in:
cybermaggedon 2024-12-03 09:52:00 +00:00 committed by GitHub
parent f24eed3023
commit df23e29971
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)
)