
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
rails-middleware-extensions
Advanced tools
Adds several additional operations useful for customizing your Rails middleware stack.
gem install rails-middleware-extensions
Just add this gem to your gemfile like so:
gem 'rails-middleware-extensions'
Currently two extensions are supported: move
and insert_unless_exists
.
As the name implies, the given middleware will only be inserted if it has not already been added to the middleware stack. For example, here's how we might insert our custom MyCustomMiddleware
middleware before Rails::Logger
:
config.middleware.insert_unless_exists(Rails::Logger, MyCustomMiddleware)
#insert_unless_exists
supports all the arguments regular 'ol #insert
supports, meaning you can also pass an index to insert before. Here's how to insert our custom middleware at the very beginning of the stack:
config.middleware.insert_unless_exists(0, MyCustomMiddleware)
Finally, use #insert_after_unless_exists
to insert a particular middleware after another one. For example, to insert MyCustomMiddleware
after Rails::Logger
:
config.middleware.insert_after_unless_exists(Rails::Logger, MyCustomMiddleware)
As of Rails 5.0, it's not possible to delete a middleware and then re-add it (see this issue) because delete operations are always applied last. Instead, consider using #move
. For example, to move our custom middleware before Rails::Logger
:
config.middleware.move(Rails::Logger, MyCustomMiddleware)
Consider #move
's cousin, #move_after
, to move a piece of middleware after another:
config.middleware.move_after(Rails::Logger, MyCustomMiddleware)
As with #insert_unless_exists
, #move
and #move_after
also support numeric indices:
config.middleware.move(0, MyCustomMiddleware)
bundle exec rspec
should do the trick :) Rails-middleware extensions supports a number of Rails versions, hence all the Gemfiles. There is one Gemfile per supported Rails version. If you'd like to run tests against a particular version, use the BUNDLE_GEMFILE
environment variable like so:
BUNDLE_GEMFILE=Gemfile-rails-4.1.x bundle exec rspec
By default tests will run against Rails 5.2.x.
Licensed under the MIT license. See LICENSE for details.
FAQs
Unknown package
We found that rails-middleware-extensions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.