rack-subdomain 0.2.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +31 -13
- data/{LICENSE → LICENSE.md} +1 -1
- data/README.md +7 -10
- data/Rakefile +0 -1
- data/lib/rack-subdomain.rb +1 -0
- data/lib/rack/subdomain.rb +16 -5
- data/lib/rack/subdomain/version.rb +5 -0
- data/rack-subdomain-0.4.0.gem +0 -0
- data/rack-subdomain-0.4.1.gem +0 -0
- data/rack-subdomain-0.5.0.gem +0 -0
- data/rack-subdomain.gemspec +10 -9
- metadata +56 -78
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: eb8698dabd7a346578bee0b70ad7cfad99a922e1e5430bd3235ffa772275e7cf
|
4
|
+
data.tar.gz: a1bec06a3ea859f8074cf94074bc7dbe24caf3c686c70a23ef9c4252ad25b832
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 779a34cb3e6bed260d7e95fdaf007835c4909422440e42dd9207ae267091890d7089f13ecf0c86d92ec4758a2c75c15e96d37d1d5d39d71579f3ddfb0bd525b5
|
7
|
+
data.tar.gz: 49ebf73dac7826e54768b893266c9e5df29746c0a3b7651c4ffa564d3d07093ab0ebaaca304411046412ebdf3ef1aed3b2fd2a6e1b67e13fb97f4ff68e674398
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,25 +1,43 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rack-subdomain (0.
|
5
|
-
|
4
|
+
rack-subdomain (0.5.0)
|
5
|
+
ipaddress (~> 0.8.0)
|
6
|
+
rack (>= 1.2)
|
6
7
|
|
7
8
|
GEM
|
8
|
-
remote:
|
9
|
+
remote: https://rubygems.org/
|
9
10
|
specs:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
diff-lcs (1.4.4)
|
12
|
+
ipaddress (0.8.3)
|
13
|
+
minitest (2.12.1)
|
14
|
+
rack (2.2.3)
|
15
|
+
rack-test (0.8.3)
|
16
|
+
rack (>= 1.0, < 3)
|
17
|
+
rake (13.0.3)
|
18
|
+
rspec (3.10.0)
|
19
|
+
rspec-core (~> 3.10.0)
|
20
|
+
rspec-expectations (~> 3.10.0)
|
21
|
+
rspec-mocks (~> 3.10.0)
|
22
|
+
rspec-core (3.10.1)
|
23
|
+
rspec-support (~> 3.10.0)
|
24
|
+
rspec-expectations (3.10.1)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.10.0)
|
27
|
+
rspec-mocks (3.10.2)
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
+
rspec-support (~> 3.10.0)
|
30
|
+
rspec-support (3.10.2)
|
16
31
|
|
17
32
|
PLATFORMS
|
18
33
|
ruby
|
19
34
|
|
20
35
|
DEPENDENCIES
|
21
|
-
minitest (~> 2.11
|
36
|
+
minitest (~> 2.11)
|
22
37
|
rack-subdomain!
|
23
|
-
rack-test (~> 0.6
|
24
|
-
rake
|
25
|
-
rspec
|
38
|
+
rack-test (~> 0.6)
|
39
|
+
rake
|
40
|
+
rspec
|
41
|
+
|
42
|
+
BUNDLED WITH
|
43
|
+
2.1.4
|
data/{LICENSE → LICENSE.md}
RENAMED
data/README.md
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
# rack-subdomain
|
2
2
|
|
3
|
-
Rack middleware to transparently route requests with a subdomain
|
3
|
+
Rack middleware to transparently route requests with a subdomain
|
4
|
+
to a specified path with substitutions.
|
4
5
|
|
5
6
|
## Usage
|
6
7
|
|
7
8
|
### Gemfile
|
8
9
|
|
9
|
-
```
|
10
|
+
```ruby
|
10
11
|
gem 'rack-subdomain'
|
11
12
|
```
|
12
13
|
|
13
14
|
### config.ru
|
14
15
|
|
15
|
-
```
|
16
|
-
|
16
|
+
```ruby
|
17
17
|
# Simple Example
|
18
18
|
|
19
19
|
use Rack::Subdomain, "example.com", to: "/users/:subdomain"
|
@@ -27,12 +27,9 @@ end
|
|
27
27
|
|
28
28
|
## Contact
|
29
29
|
|
30
|
-
Mattt
|
31
|
-
|
32
|
-
- http://github.com/mattt
|
33
|
-
- http://twitter.com/mattt
|
34
|
-
- m@mattt.me
|
30
|
+
[Mattt](https://twitter.com/mattt)
|
35
31
|
|
36
32
|
## License
|
37
33
|
|
38
|
-
rack-subdomain is available under the MIT license.
|
34
|
+
rack-subdomain is available under the MIT license.
|
35
|
+
See the LICENSE file for more info.
|
data/Rakefile
CHANGED
data/lib/rack-subdomain.rb
CHANGED
data/lib/rack/subdomain.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
+
require 'ipaddress'
|
2
|
+
|
1
3
|
module Rack
|
2
4
|
class Subdomain
|
3
|
-
VERSION = '0.2.1'
|
4
|
-
|
5
5
|
def initialize(app, domain, options = {}, &block)
|
6
6
|
# Maintain compatibility with previous rack-subdomain gem
|
7
7
|
options = {to: options} if options.is_a? String
|
@@ -20,7 +20,7 @@ module Rack
|
|
20
20
|
raise ArgumentError, "missing `:to` option or block to define mapping"
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def call(env)
|
25
25
|
@env = env
|
26
26
|
@subdomain = subdomain
|
@@ -49,13 +49,24 @@ module Rack
|
|
49
49
|
|
50
50
|
private
|
51
51
|
|
52
|
+
def domain
|
53
|
+
case @domain
|
54
|
+
when Proc
|
55
|
+
@domain.call(@env['HTTP_HOST'])
|
56
|
+
when Regexp
|
57
|
+
@domain.match(@env['HTTP_HOST'])
|
58
|
+
else
|
59
|
+
@domain
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
52
63
|
def subdomain
|
53
|
-
@env['HTTP_HOST'].sub(/\.?#{
|
64
|
+
@env['HTTP_HOST'].sub(/\.?#{domain}.*$/,'') unless @env['HTTP_HOST'].nil? || @env['HTTP_HOST'].match(/^localhost/) || IPAddress.valid?(@env['SERVER_NAME'])
|
54
65
|
end
|
55
66
|
|
56
67
|
def remap_with_substituted_path!(path)
|
57
68
|
scheme = @env["rack.url_scheme"]
|
58
|
-
host = "#{@subdomain}.#{
|
69
|
+
host = "#{@subdomain}.#{domain}"
|
59
70
|
port = ":#{@env['SERVER_PORT']}" unless @env['SERVER_PORT'] == '80'
|
60
71
|
path = @env["PATH_INFO"] = ::File.join(path, @env["PATH_INFO"])
|
61
72
|
query_string = "?" + @env["QUERY_STRING"] unless @env["QUERY_STRING"].empty?
|
Binary file
|
Binary file
|
Binary file
|
data/rack-subdomain.gemspec
CHANGED
@@ -1,25 +1,26 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "rack
|
3
|
+
require "rack/subdomain/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "rack-subdomain"
|
7
|
-
s.authors = ["Mattt
|
8
|
-
s.email = "
|
7
|
+
s.authors = ["Mattt", "Piotr Sarnacki"]
|
8
|
+
s.email = "mattt@me.com"
|
9
|
+
s.license = "MIT"
|
9
10
|
s.homepage = "http://github.com/mattt/rack-subdomain"
|
10
11
|
s.version = Rack::Subdomain::VERSION
|
11
12
|
s.platform = Gem::Platform::RUBY
|
12
13
|
s.summary = "rack-subdomain"
|
13
14
|
s.description = "Rack middleware to route requests with subdomains to specified routes with substitutions"
|
14
15
|
|
15
|
-
s.
|
16
|
-
s.add_development_dependency "rake", "~> 0.9.2"
|
16
|
+
s.add_runtime_dependency "rack", ">= 1.2"
|
17
17
|
|
18
|
-
s.
|
18
|
+
s.add_dependency "ipaddress", "~> 0.8.0"
|
19
19
|
|
20
|
-
s.add_development_dependency "
|
21
|
-
s.add_development_dependency "
|
22
|
-
s.add_development_dependency "
|
20
|
+
s.add_development_dependency "rspec"
|
21
|
+
s.add_development_dependency "rake"
|
22
|
+
s.add_development_dependency "minitest", "~> 2.11"
|
23
|
+
s.add_development_dependency "rack-test", "~> 0.6"
|
23
24
|
|
24
25
|
s.files = Dir["./**/*"].reject { |file| file =~ /\.\/(bin|log|pkg|script|spec|test|vendor)/ }
|
25
26
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,162 +1,140 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-subdomain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.5.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
|
-
- Mattt
|
7
|
+
- Mattt
|
9
8
|
- Piotr Sarnacki
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2021-03-02 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
15
|
+
name: rack
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
|
-
- -
|
18
|
+
- - ">="
|
21
19
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
23
|
-
type: :
|
20
|
+
version: '1.2'
|
21
|
+
type: :runtime
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
|
-
- -
|
25
|
+
- - ">="
|
29
26
|
- !ruby/object:Gem::Version
|
30
|
-
version:
|
27
|
+
version: '1.2'
|
31
28
|
- !ruby/object:Gem::Dependency
|
32
|
-
name:
|
29
|
+
name: ipaddress
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
31
|
requirements:
|
36
|
-
- - ~>
|
32
|
+
- - "~>"
|
37
33
|
- !ruby/object:Gem::Version
|
38
|
-
version: 0.
|
39
|
-
type: :
|
34
|
+
version: 0.8.0
|
35
|
+
type: :runtime
|
40
36
|
prerelease: false
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
38
|
requirements:
|
44
|
-
- - ~>
|
39
|
+
- - "~>"
|
45
40
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.
|
41
|
+
version: 0.8.0
|
47
42
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
43
|
+
name: rspec
|
49
44
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
45
|
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 1.2.0
|
55
|
-
- - <=
|
46
|
+
- - ">="
|
56
47
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
58
|
-
type: :
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
59
50
|
prerelease: false
|
60
51
|
version_requirements: !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
52
|
requirements:
|
63
|
-
- -
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version: 1.2.0
|
66
|
-
- - <=
|
53
|
+
- - ">="
|
67
54
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
55
|
+
version: '0'
|
69
56
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
57
|
+
name: rake
|
71
58
|
requirement: !ruby/object:Gem::Requirement
|
72
|
-
none: false
|
73
59
|
requirements:
|
74
|
-
- -
|
60
|
+
- - ">="
|
75
61
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
62
|
+
version: '0'
|
77
63
|
type: :development
|
78
64
|
prerelease: false
|
79
65
|
version_requirements: !ruby/object:Gem::Requirement
|
80
|
-
none: false
|
81
66
|
requirements:
|
82
|
-
- -
|
67
|
+
- - ">="
|
83
68
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
69
|
+
version: '0'
|
85
70
|
- !ruby/object:Gem::Dependency
|
86
|
-
name:
|
71
|
+
name: minitest
|
87
72
|
requirement: !ruby/object:Gem::Requirement
|
88
|
-
none: false
|
89
73
|
requirements:
|
90
|
-
- - ~>
|
74
|
+
- - "~>"
|
91
75
|
- !ruby/object:Gem::Version
|
92
|
-
version:
|
76
|
+
version: '2.11'
|
93
77
|
type: :development
|
94
78
|
prerelease: false
|
95
79
|
version_requirements: !ruby/object:Gem::Requirement
|
96
|
-
none: false
|
97
80
|
requirements:
|
98
|
-
- - ~>
|
81
|
+
- - "~>"
|
99
82
|
- !ruby/object:Gem::Version
|
100
|
-
version:
|
83
|
+
version: '2.11'
|
101
84
|
- !ruby/object:Gem::Dependency
|
102
|
-
name:
|
85
|
+
name: rack-test
|
103
86
|
requirement: !ruby/object:Gem::Requirement
|
104
|
-
none: false
|
105
87
|
requirements:
|
106
|
-
- - ~>
|
88
|
+
- - "~>"
|
107
89
|
- !ruby/object:Gem::Version
|
108
|
-
version: 0.
|
90
|
+
version: '0.6'
|
109
91
|
type: :development
|
110
92
|
prerelease: false
|
111
93
|
version_requirements: !ruby/object:Gem::Requirement
|
112
|
-
none: false
|
113
94
|
requirements:
|
114
|
-
- - ~>
|
95
|
+
- - "~>"
|
115
96
|
- !ruby/object:Gem::Version
|
116
|
-
version: 0.
|
97
|
+
version: '0.6'
|
117
98
|
description: Rack middleware to route requests with subdomains to specified routes
|
118
99
|
with substitutions
|
119
|
-
email:
|
100
|
+
email: mattt@me.com
|
120
101
|
executables: []
|
121
102
|
extensions: []
|
122
103
|
extra_rdoc_files: []
|
123
104
|
files:
|
124
|
-
- ./Gemfile
|
125
|
-
- ./Gemfile.lock
|
126
|
-
- ./
|
127
|
-
- ./
|
128
|
-
- ./
|
129
|
-
- ./rack-subdomain.
|
130
|
-
- ./
|
131
|
-
- ./
|
105
|
+
- "./Gemfile"
|
106
|
+
- "./Gemfile.lock"
|
107
|
+
- "./LICENSE.md"
|
108
|
+
- "./README.md"
|
109
|
+
- "./Rakefile"
|
110
|
+
- "./lib/rack-subdomain.rb"
|
111
|
+
- "./lib/rack/subdomain.rb"
|
112
|
+
- "./lib/rack/subdomain/version.rb"
|
113
|
+
- "./rack-subdomain-0.4.0.gem"
|
114
|
+
- "./rack-subdomain-0.4.1.gem"
|
115
|
+
- "./rack-subdomain-0.5.0.gem"
|
116
|
+
- "./rack-subdomain.gemspec"
|
132
117
|
homepage: http://github.com/mattt/rack-subdomain
|
133
|
-
licenses:
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata: {}
|
134
121
|
post_install_message:
|
135
122
|
rdoc_options: []
|
136
123
|
require_paths:
|
137
124
|
- lib
|
138
125
|
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
-
none: false
|
140
126
|
requirements:
|
141
|
-
- -
|
127
|
+
- - ">="
|
142
128
|
- !ruby/object:Gem::Version
|
143
129
|
version: '0'
|
144
|
-
segments:
|
145
|
-
- 0
|
146
|
-
hash: -539744315784908145
|
147
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
-
none: false
|
149
131
|
requirements:
|
150
|
-
- -
|
132
|
+
- - ">="
|
151
133
|
- !ruby/object:Gem::Version
|
152
134
|
version: '0'
|
153
|
-
segments:
|
154
|
-
- 0
|
155
|
-
hash: -539744315784908145
|
156
135
|
requirements: []
|
157
|
-
|
158
|
-
rubygems_version: 1.8.24
|
136
|
+
rubygems_version: 3.1.2
|
159
137
|
signing_key:
|
160
|
-
specification_version:
|
138
|
+
specification_version: 4
|
161
139
|
summary: rack-subdomain
|
162
140
|
test_files: []
|