ticket:3 middleware implementation