Move the statusCode recording in its own middleware