Added heartbeat middleware for /ping endpoint