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.
Files changed (3) hide show
  1. data/README.rdoc +8 -0
  2. data/lib/rack/subdomain.rb +7 -2
  3. 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.
@@ -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
- path_info = @env["PATH_INFO"]
35
- @env["PATH_INFO"] = "#{@map_to}#{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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Piotr Sarnacki