Class: Rack::Rewrite
- Inherits:
-
Object
- Object
- Rack::Rewrite
- Defined in:
- lib/rack/rewrite.rb,
lib/rack/rewrite/rule.rb,
lib/rack/rewrite/version.rb
Overview
A rack middleware for defining and applying rewrite rules. In many cases you can get away with rack-rewrite instead of writing Apache mod_rewrite rules.
Defined Under Namespace
Constant Summary collapse
- VERSION =
File.read File.join(File.("..", __FILE__), "..", "..", "..", "VERSION")
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, &rule_block) ⇒ Rewrite
constructor
A new instance of Rewrite.
Constructor Details
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/rack/rewrite.rb', line 14 def call(env) if matched_rule = find_first_matching_rule(env) rack_response = matched_rule.apply!(env) # Don't invoke the app if applying the rule returns a rack response return rack_response unless rack_response === true end @app.call(env) end |