knutin/elli — pull request #71 by arobson (2013-10-21 04:42:55+00:00)
Title: Add support for Upgrade to Elli (making web socket middleware possible)

I only found out about the other branch after I had completed this one. With this approach, you have to specify {upgrade, true} as an option when setting up Elli.

If upgrading has been enabled, any middleware or callback module can return {upgrade, Callback} where Callback is a function that takes the request header list, the request body and the underlying socket. Elli will activate this callback and relinquish control of the Socket.

I've tried to add some (rather minimalistic) test coverage to show how an upgrade gets treated if it's not been enabled.

Take a look at http://github.com/arobson/elli_websockets to see how I'm currently using this. The websocket middleware presently only supports hybi. I plan to add support for SSL against the SSL branch for the middleware soon.