Fix middleware signature