probably the default middlewares should be attached to the function itself, something like mojito.middlewares[mid], where the function also acts like an object with members.