class Rack::Builder

def freeze_app

in to_app.
Freeze the app (set using run) and all middleware instances when building the application
def freeze_app
  @freeze_app = true
end