abstracting http/websocket requests