Move middlware into its own gem