rack-subdomain 0.0.1 → 0.0.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.rdoc +8 -0
- data/lib/rack/subdomain.rb +7 -2
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
Simple rack middleware for fetching subdomain from request and modyfing path with fetched subdomain.
|
4
4
|
|
5
|
+
== Usage
|
6
|
+
|
7
|
+
Example for rails app:
|
8
|
+
|
9
|
+
config.middleware.use(Rack::Subdomain, "example.org", "/users/:subdomain")
|
10
|
+
|
11
|
+
This will get subdomains for domain example.org (ie. something.example.org) and will map path to /users/:subdomain/original/path.
|
12
|
+
|
5
13
|
== Note on Patches/Pull Requests
|
6
14
|
|
7
15
|
* Fork the project.
|
data/lib/rack/subdomain.rb
CHANGED
@@ -31,8 +31,13 @@ module Rack
|
|
31
31
|
def map_to(subdomain)
|
32
32
|
if @map_to
|
33
33
|
@map_to.gsub!(":subdomain", subdomain)
|
34
|
-
|
35
|
-
@env["PATH_INFO"] =
|
34
|
+
new_path_info = "#{@map_to}#{@env["PATH_INFO"]}"
|
35
|
+
@env["PATH_INFO"] = new_path_info
|
36
|
+
new_request_uri = new_path_info.dup
|
37
|
+
if @env["QUERY_STRING"]
|
38
|
+
new_request_uri << "?" << @env["QUERY_STRING"]
|
39
|
+
end
|
40
|
+
@env["REQUEST_URI"] = new_request_uri
|
36
41
|
end
|
37
42
|
end
|
38
43
|
end
|