Apply the middleware pattern to any property or function