This is a generalized library for using middleware patterns within your Ruby projects.
To get started, the best place to look is the user guide.
This project is distributed as a RubyGem:
$ gem install middlewareOnce you create a basic middleware, you can use the builder to have a nice DSL to build middleware stacks. Calling the middleware is simple, as well.
# Basic middleware that just prints the inbound and# outbound steps.classTracedefinitialize(app,value)@app=app@value=valueenddefcall(env)puts"--> #{@value}"@app.call(env)puts"<-- #{@value}"endend# Build the actual middleware stack which runs a sequence# of slightly different versions of our middleware.stack=Middleware::Builder.newdouseTrace,"A"useTrace,"B"useTrace,"C"end# Run it!stack.call(nil)And the output:
--> A
--> B
--> C
<-- C
<-- B
<-- A
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Added some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
