Generate middleware which simulates network latency