probably we should call this `dispatcherMiddleware` instead of `mid` for better docs.