Add debug to endpoint

This commit is contained in:
Cyber MacGeddon 2024-12-03 09:50:54 +00:00
parent 1b9c6be4fc
commit 20201b3898

View file

@ -62,6 +62,8 @@ class ServiceEndpoint:
id = str(uuid.uuid4()) id = str(uuid.uuid4())
print(request.path, "...")
try: try:
ht = request.headers["Authorization"] ht = request.headers["Authorization"]
tokens = ht.split(" ", 2) tokens = ht.split(" ", 2)
@ -78,23 +80,31 @@ class ServiceEndpoint:
data = await request.json() data = await request.json()
print(data)
q = await self.sub.subscribe(id) q = await self.sub.subscribe(id)
await self.pub.send( await self.pub.send(
id, id,
self.to_request(data), self.to_request(data),
) )
print("Request sent")
try: try:
resp = await asyncio.wait_for(q.get(), self.timeout) resp = await asyncio.wait_for(q.get(), self.timeout)
except: except:
raise RuntimeError("Timeout waiting for response") raise RuntimeError("Timeout waiting for response")
print("Response got")
if resp.error: if resp.error:
print("Error")
return web.json_response( return web.json_response(
{ "error": resp.error.message } { "error": resp.error.message }
) )
print("Send response")
return web.json_response( return web.json_response(
self.from_response(resp) self.from_response(resp)
) )