make the handshake thing a middleware/request handler