A swift middleware for handling metadata