davejachimiak/vega_server — pull request #3 by davejachimiak (2014-10-03 18:40:30+00:00)
Title: Add middleware functionality for incoming call messages

Summary
-------
This runs middleware on incoming call messages. It allows custom
middlewares to be configured.

Middlewares must return either a
`VegaServer::IncomingMessages::CallResponse::Accept` or
`VegaServer::IncomingMessages::CallResponse::Reject` object.

The objects returned by middlewares are effectively values of the Either
monad, where `Accept client_caller` represents `Right b` and `Reject
error` represents `Left a`. The object responsible for incoming calls
calls consecutive middlewares as functions to `#bind`. As is expected by
the Either monad, the middleware chain is stopped whenever a `Reject`
object is returned by some middleware.

This adds a default middleware that checks whether a room id is in the
call payload.