middleware template