adds middleware function to connect:server