Reimplement everything as Rack middleware.