/usr/share/doc/ruby-middleware/README.md is in ruby-middleware 0.1.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | # Middleware
[![Build Status](https://secure.travis-ci.org/mitchellh/middleware.png?branch=master)](http://travis-ci.org/mitchellh/middleware)
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](https://github.com/mitchellh/middleware/blob/master/user_guide.md).
## Installation
This project is distributed as a RubyGem:
$ gem install middleware
## Usage
Once 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.
```ruby
# Basic middleware that just prints the inbound and
# outbound steps.
class Trace
def initialize(app, value)
@app = app
@value = value
end
def call(env)
puts "--> #{@value}"
@app.call(env)
puts "<-- #{@value}"
end
end
# Build the actual middleware stack which runs a sequence
# of slightly different versions of our middleware.
stack = Middleware::Builder.new do
use Trace, "A"
use Trace, "B"
use Trace, "C"
end
# Run it!
stack.call(nil)
```
And the output:
```
--> A
--> B
--> C
<-- C
<-- B
<-- A
```
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
|