Rack middleware for conditionally redirecting to another domain
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
lib/rack
test
.document
.gitignore
LICENSE
README.rdoc
Rakefile
VERSION

README.rdoc

Rack::DomainRedirect

Description

Rack::DomainRedirect is a tiny rack middleware for redirecting to the configurable domain. If user request's the service from domain other than that configured it redirects to the first domain on the configuration list. If no domain is configured it does noting and passes requests to another application in the chain.

Features

  • Configurable accepted domains,

  • if not configured it degrades nicely and does nothing,

  • preserves path and query string when redirecting.

Example

# This example allows requests for example.com and localhost.
# If any other domain is requested it redirects to the first domain on the
# list - example.com preserving path and query string from the first request.
require "rack/domain_redirect"

# This is how you use and configure Rack::DomainRedirect middleware
use Rack::DomainRedirect, ['example.com', 'localhost']

run lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['Hello world!']] }

Install

To install the latest release as a gem:

sudo gem install rack-domain_redirect

Credits

Many thanks to brynary for github.com/brynary/rack-test

Copyright

Copyright © 2010 Michal Pawlowski, itsudo ltd See LICENSE for details.