Created
February 3, 2022 00:14
-
-
Save xanderificnl/2918d9645fd38acc14e16b132e21601b to your computer and use it in GitHub Desktop.
Convenient helper to load application middleware into Rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# Convenient helper to load application middleware into Rails. | |
# | |
# @example app/middleware/health_middleware.rb | |
# class HealthMiddleware; end | |
# | |
Pathname.glob(Rails.root.join("app/middleware/*.rb")).each do |path| | |
require path | |
# Unfold the path into something useful. | |
middleware = path.basename(path.extname).to_path.classify.constantize | |
Rails.configuration.middleware.use(middleware) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment