Configurable middleware stack

Hi. I need capability to insert my own middlewares so i try to make it by myself. Here is the result. Take a look.