add middleware to rest