Implement middleware connect method.