rack-vhost 0.1.0
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/.gitignore +1 -0
- data/README.md +4 -0
- data/examples/config.ru +23 -0
- data/lib/rack/vhost.rb +17 -0
- data/rack-vhost.gemspec +17 -0
- metadata +65 -0
data/.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*.gem
|
data/README.md
ADDED
data/examples/config.ru
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'rack/vhost'
|
|
2
|
+
|
|
3
|
+
class Router
|
|
4
|
+
def call(env)
|
|
5
|
+
'Router app'
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class APIApp
|
|
10
|
+
def call(env)
|
|
11
|
+
'API app'
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class MainApp
|
|
16
|
+
def call(env)
|
|
17
|
+
'Main app'
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
use Rack::Vhost, :vhost => '/^api/', :app => APIApp.new
|
|
22
|
+
use Rack::Vhost, :vhost => '/www.philcolabs.com/', :app => MainApp.new
|
|
23
|
+
run Router
|
data/lib/rack/vhost.rb
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Rack
|
|
2
|
+
class Vhost
|
|
3
|
+
def initialize(app, args)
|
|
4
|
+
@app = app
|
|
5
|
+
@sub_app = args[:app]
|
|
6
|
+
@regex = args[:vhost]
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def call(env)
|
|
10
|
+
if env['HTTP_HOST'] =~ @regex
|
|
11
|
+
@sub_app.call(env)
|
|
12
|
+
else
|
|
13
|
+
@app.call(env)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
data/rack-vhost.gemspec
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Gem::Specification.new do |gem|
|
|
2
|
+
gem.name = 'rack-vhost'
|
|
3
|
+
gem.version = '0.1.0'
|
|
4
|
+
gem.summary = 'Rack middleware to dispatch to an application via host header'
|
|
5
|
+
gem.description = 'Rack middleware to dispatch to an application via host header.'
|
|
6
|
+
gem.author = 'Philip Reichenberger'
|
|
7
|
+
gem.email = 'preichenberger@philcolabs.com'
|
|
8
|
+
gem.homepage = 'http://github.com/preichen/rack-vhost'
|
|
9
|
+
gem.has_rdoc = false
|
|
10
|
+
gem.require_path = 'lib'
|
|
11
|
+
|
|
12
|
+
gem.files = `git ls-files`.split($/)
|
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
14
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
15
|
+
|
|
16
|
+
gem.add_development_dependency 'rack'
|
|
17
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: rack-vhost
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Philip Reichenberger
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-11-07 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: rack
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
type: :development
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ! '>='
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '0'
|
|
30
|
+
description: Rack middleware to dispatch to an application via host header.
|
|
31
|
+
email: preichenberger@philcolabs.com
|
|
32
|
+
executables: []
|
|
33
|
+
extensions: []
|
|
34
|
+
extra_rdoc_files: []
|
|
35
|
+
files:
|
|
36
|
+
- .gitignore
|
|
37
|
+
- README.md
|
|
38
|
+
- examples/config.ru
|
|
39
|
+
- lib/rack/vhost.rb
|
|
40
|
+
- rack-vhost.gemspec
|
|
41
|
+
homepage: http://github.com/preichen/rack-vhost
|
|
42
|
+
licenses: []
|
|
43
|
+
post_install_message:
|
|
44
|
+
rdoc_options: []
|
|
45
|
+
require_paths:
|
|
46
|
+
- lib
|
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
48
|
+
none: false
|
|
49
|
+
requirements:
|
|
50
|
+
- - ! '>='
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: '0'
|
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
|
+
none: false
|
|
55
|
+
requirements:
|
|
56
|
+
- - ! '>='
|
|
57
|
+
- !ruby/object:Gem::Version
|
|
58
|
+
version: '0'
|
|
59
|
+
requirements: []
|
|
60
|
+
rubyforge_project:
|
|
61
|
+
rubygems_version: 1.8.24
|
|
62
|
+
signing_key:
|
|
63
|
+
specification_version: 3
|
|
64
|
+
summary: Rack middleware to dispatch to an application via host header
|
|
65
|
+
test_files: []
|