Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def _handle_request(self, request):
result = {
"id": request.get("id", 0),
"result": None,
"error": None
}
response = await methods.dispatch(request)
result.update(response)
if result['error'] and result['error']['code'] < -32:
result['error']['code'] = -1
return result, response.http_status
async def dispatch(request):
try:
req = json.loads(request.body.decode())
req["params"] = req.get("params", {})
except JSONDecodeError:
raise GenericJsonRpcServerError(
code=-32700,
message="Parse error",
http_status=status.HTTP_BAD_REQUEST
)
else:
res = await methods.dispatch(req)
return sanic_response.json(res, status=res.http_status)
async def handle(request):
request = await request.text()
# print(request)
response = await methods.dispatch(request)
if response.is_notification:
return web.Response()
else:
return web.json_response(response, status=response.http_status)
async def main(websocket, path):
request = await websocket.recv()
response = await methods.dispatch(request)
if not response.is_notification:
await websocket.send(str(response))
async def handle(request):
request = await request.text()
response = await methods.dispatch(request)
if response.is_notification:
return web.Response()
else:
return web.json_response(response, status=response.http_status)
async def handle(request):
request = await request.text()
response = await methods.dispatch(request)
if response.is_notification:
return web.Response()
else:
return web.json_response(response, status=response.http_status)