No commit activity in last 3 years
No release in over 3 years
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.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 1.1
 Project Readme

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 © 2010 Michal Pawlowski, itsudo ltd See LICENSE for details.