Code Monkey home page Code Monkey logo

rack-domain_redirect's Introduction

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.

rack-domain_redirect's People

Contributors

misza222 avatar maccman avatar

Watchers

 avatar Jonathan Cutrell avatar Kiernan Tim McGowan avatar Ethan Hackett avatar Roberto Rodriguez avatar João Moura avatar Matt Sornson avatar Chris Wake avatar Matt Aitchison avatar James Cloos avatar David Lumley avatar Oguz Huner avatar John Otander avatar Andrew O'Neal avatar Shirley Shaw avatar Benton Anderson avatar Tom Richards avatar Edward Huang avatar Ben Stevenson avatar Emily Brown avatar  avatar David Noah avatar  avatar

Forkers

isabella232

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.