Initial, raw implementation of the middleware.