title: Is there a concept of a middleware in CodeIgniter?
body: <p>I want to do some pre and post processing of requests like handling authentication, loading contextual data, performance timings and things like that. Coming from Django there's a concept of <code>MIDDLEWARE_CLASSES</code> that lets me handle the request in various stages: <a href="https://docs.djangoproject.com/en/dev/topics/http/middleware/" rel="noreferrer">https://docs.djangoproject.com/en/dev/topics/http/middleware/</a></p>
  
  <p>Currently it seems like each Controller has to do the same setup and load, in the constructor which isn't ideal because if the constructor fails, the class doesn't get initialized which has subtle but important consequences. I want to move this global handling to a global place.</p>
  
  <p>Any suggestions?</p>