rack-vhost 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -2,3 +2,29 @@ rack-vhost
2
2
  ==========
3
3
 
4
4
  Rack middleware to dispatch to an application via host header.
5
+
6
+ Example config.ru:
7
+
8
+ require 'rack/vhost'
9
+
10
+ class Router
11
+ def call(env)
12
+ [200, { 'Content-Type' => 'text/plain' }, 'Router app']
13
+ end
14
+ end
15
+
16
+ class APIApp
17
+ def call(env)
18
+ [200, { 'Content-Type' => 'text/plain' }, 'API app']
19
+ end
20
+ end
21
+
22
+ class MainApp
23
+ def call(env)
24
+ [200, { 'Content-Type' => 'text/plain' }, 'Main app']
25
+ end
26
+ end
27
+
28
+ use Rack::Vhost, :vhost => '^api', :app => APIApp.new
29
+ use Rack::Vhost, :vhost => 'www.philcolabs.com', :app => MainApp.new
30
+ run Router.new
data/examples/config.ru CHANGED
@@ -18,6 +18,6 @@ class MainApp
18
18
  end
19
19
  end
20
20
 
21
- use Rack::Vhost, :vhost => /^api/, :app => APIApp.new
22
- use Rack::Vhost, :vhost => /www.philcolabs.com/, :app => MainApp.new
21
+ use Rack::Vhost, :vhost => '^api', :app => APIApp.new
22
+ use Rack::Vhost, :vhost => 'www.philcolabs.com', :app => MainApp.new
23
23
  run Router.new
data/lib/rack/vhost.rb CHANGED
@@ -3,7 +3,7 @@ module Rack
3
3
  def initialize(app, args)
4
4
  @app = app
5
5
  @sub_app = args[:app]
6
- @regex = args[:vhost]
6
+ @regex = Regexp.new(args[:vhost].to_s)
7
7
  end
8
8
 
9
9
  def call(env)
data/rack-vhost.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'rack-vhost'
3
- gem.version = '0.1.1'
3
+ gem.version = '0.1.2'
4
4
  gem.summary = 'Rack middleware to dispatch to an application via host header'
5
5
  gem.description = 'Rack middleware to dispatch to an application via host header.'
6
6
  gem.author = 'Philip Reichenberger'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-vhost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: