No commit activity in last 3 years
No release in over 3 years
Discover rack middleware
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Rack::Capabilities¶ ↑

Usage¶ ↑

class CuriousMiddleware
  def initialize(app)
    @app = app
  end

  def curious?
    true #and how!
  end

  def call(env)
    # who is before me?
    env['rack.capabilities'].before(self)
    # returns Rack::Middleware2

    # who is after me?
    env['rack.capabilities'].after(self)
    # returns Rack::Middleware4

    # can I go find Rack::Middleware1?
    env['rack.capabilities'].find(Rack::Middleware1)
    # returns Rack::Middleware1

    # or just find based on anything!
    env['rack.capabilities'].find{|mw| mw.respond_to?(:curious?)}
    # returns our friend, CuriousMiddleware

    # And presumably you'd
    # want to do stuff..
    # but thats up to you

    @app.call(env)
  end

end

use Rack::Capabilities
use Rack::Middleware1
use Rack::Middleware2
use Rack::CuriousMiddleware
use Rack::Middleware4
use Rack::Middleware5

Caveats and Limitations¶ ↑

Rack::Capabilities must be required (not autoloaded as it must monkey patch Rack::Builder). The rack.capabilities environment variable is only available at call time.