middleware for injecting ticket into template