Swift middleware