Project

rack-vhost

0.0
No commit activity in last 3 years
No release in over 3 years
Rack middleware to dispatch to an application via host header.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
 Project Readme

rack-vhost

Rack middleware to dispatch to an application via host header.

Install gem:

gem install rack-vhost

or in Gemfile:

source :rubygems
gem 'rack-vhost'

Example config.ru:

require 'rack/vhost'

class Router
  def call(env)
    [200, { 'Content-Type' => 'text/plain' }, 'Router app']
  end
end

class APIApp
  def call(env)
    [200, { 'Content-Type' => 'text/plain' }, 'API app']
  end
end

class MainApp
  def call(env)
    [200, { 'Content-Type' => 'text/plain' }, 'Main app']
  end
end

# This should come after all other middleware since it passes directly to the app
use Rack::Vhost, :vhost => '^api', :app => APIApp.new
use Rack::Vhost, :vhost => 'www.philcolabs.com', :app => MainApp.new
run Router.new