Implement rack middleware

![screenshot](https://cloud.githubusercontent.com/assets/2900644/4085317/aae2130e-2f19-11e4-8588-e6e7e9a8798f.png)