Class: Rack::Rewrite

### Home Classes Methods

### In Files

- lib/rack/rewrite.rb
- lib/rack/rewrite/rule.rb
- lib/rack/rewrite/version.rb

### Parent

Object

### Namespace

- CLASS Rack::Rewrite::RuleSet

### Methods

- ::new
- #call

### Class/Module Index

Quicksearch

- Rack
- Rack::Rewrite
- Rack::Rewrite::RuleSet

No matching classes.

# Rack::Rewrite

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.

### Constants

VERSION

### Public Class Methods

new(app, &rule_block) click to toggle source

    # File lib/rack/rewrite.rb, line 8
    def initialize(app, &rule_block)
      @app = app
      @rule_set = RuleSet.new
      @rule_set.instance_eval(&rule_block) if block_given?
    end

### Public Instance Methods

call(env) click to toggle source

    # 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.