rails_reroute 0.2.6 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b47a664e2297691034a8810a6a88a7997dae33b
4
- data.tar.gz: 8d996f2e02c7d145342ca1dc758f67564859fe0a
3
+ metadata.gz: c1a983a05c0141e0ef9174adb8b2d5dcd1085cc8
4
+ data.tar.gz: 4e81869f7a4a049fe86d7d4ce5c33c8a5261094c
5
5
  SHA512:
6
- metadata.gz: 3498559f4d991911c28d95dfbdbd185c69bcbf3332a7db67e4223dc8c375f8a034af950a1d0e974de46704b0dfce5586bc137785348effb1711b6e006ffa1ff1
7
- data.tar.gz: 8148c70f888ad66214ad03ea64961062526a70504740437b913a921ffbf71e88d73b6c5f2a3ee55e291acb6204c60b15df9d9fade28323b1eac2fedb3b046f92
6
+ metadata.gz: 5b5a8f8648a9b6d7fd0b42c54bc6c86596002dd0e2031b5b514a02586d2184277a9737367b5e792882ac64d689eef0f4906f39460949f91761251fb29566595e
7
+ data.tar.gz: 293752610774d2c94108d4eafc15cfec3092bc8af8a9ab4a04212e46da80761c36225c1205d08c1017cbcb88b5679ac712c280b4735f9a5d0e4727ec1bcc44fa
@@ -0,0 +1,35 @@
1
+ module RailsReroute
2
+ DEFAULT_VARIABLES = Set.new(%W[
3
+ CONTENT_TYPE
4
+ CONTENT_LENGTH
5
+ HTTPS
6
+ AUTH_TYPE
7
+ HTTP_COOKIE
8
+ GATEWAY_INTERFACE
9
+ PATH_INFO
10
+ PATH_TRANSLATED
11
+ QUERY_STRING
12
+ REMOTE_ADDR
13
+ REMOTE_HOST
14
+ REMOTE_IDENT
15
+ REMOTE_USER
16
+ REQUEST_METHOD
17
+ SCRIPT_NAME
18
+ SERVER_NAME
19
+ SERVER_PORT
20
+ SERVER_PROTOCOL
21
+ SERVER_SOFTWARE
22
+ HTTP_TE
23
+ HTTP_CONNECTION
24
+ HTTP_ACCEPT_ENCODING
25
+ HTTP_AKAMAI_ORIGIN_HOP
26
+ HTTP_VIA
27
+ HTTP_X_AKAMAI_EDGESCAPE
28
+ HTTP_X_FORWARDED_FOR
29
+ HTTP_TRUE_CLIENT_IP
30
+ HTTP_HOST
31
+ HTTP_CACHE_CONTROL
32
+ HTTP_REFERER
33
+ HTTP_USER_AGENT
34
+ ]).freeze
35
+ end
@@ -1,3 +1,5 @@
1
+ require 'default_variables'
2
+
1
3
  module RailsReroute
2
4
  class Railtie < Rails::Railtie
3
5
  initializer "rails_reroute.initializer" do
@@ -10,21 +12,18 @@ module RailsReroute
10
12
  @_response_body = @_response.body
11
13
  end
12
14
 
13
- def reroute_default_variables
14
- %w( CONTENT_TYPE CONTENT_LENGTH
15
- HTTPS AUTH_TYPE HTTP_COOKIE GATEWAY_INTERFACE
16
- PATH_INFO PATH_TRANSLATED QUERY_STRING
17
- REMOTE_ADDR REMOTE_HOST REMOTE_IDENT REMOTE_USER
18
- REQUEST_METHOD SCRIPT_NAME
19
- SERVER_NAME SERVER_PORT SERVER_PROTOCOL SERVER_SOFTWARE
20
- HTTP_TE HTTP_CONNECTION HTTP_ACCEPT_ENCODING HTTP_AKAMAI_ORIGIN_HOP HTTP_VIA HTTP_X_AKAMAI_EDGESCAPE
21
- HTTP_X_FORWARDED_FOR HTTP_TRUE_CLIENT_IP HTTP_HOST HTTP_CACHE_CONTROL HTTP_REFERER HTTP_USER_AGENT )
22
- end
23
-
24
15
  def reroute_new_env new_route
25
- new_paths = {"PATH_INFO" => "#{new_route}", "REQUEST_URI"=>"#{env["rack.url_scheme"]}://#{env["HTTP_HOST"]}#{new_route}", "REQUEST_PATH"=>"#{new_route}",
26
- "ORIGINAL_REQUEST_URI" => env["REQUEST_URI"]}
27
- env.keys.each { |key| env.delete(key) if !reroute_default_variables.include?(key) and !key.include?("rack") }
16
+ new_paths = {
17
+ "PATH_INFO" => "#{new_route}",
18
+ "REQUEST_URI"=>"#{env["rack.url_scheme"]}://#{env["HTTP_HOST"]}#{new_route}",
19
+ "REQUEST_PATH"=>"#{new_route}",
20
+ "ORIGINAL_REQUEST_URI" => env["REQUEST_URI"]
21
+ }
22
+
23
+ env.select! do |key, value|
24
+ DEFAULT_VARIABLES.include?(key) || key.include?("rack")
25
+ end
26
+
28
27
  env.merge! new_paths
29
28
  end
30
29
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rails_reroute"
3
- s.version = "0.2.6"
3
+ s.version = "0.2.8"
4
4
 
5
5
  s.authors = ["Nathaniel Barnes"]
6
6
  s.email = ["Nathaniel.R.Barnes@gmail.com"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_reroute
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathaniel Barnes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-17 00:00:00.000000000 Z
11
+ date: 2016-05-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Reroute rails requests fully
14
14
  email:
@@ -17,11 +17,12 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - ".gitignore"
20
+ - .gitignore
21
21
  - Gemfile
22
22
  - LICENSE
23
23
  - README.md
24
24
  - Rakefile
25
+ - lib/default_variables.rb
25
26
  - lib/rails_reroute.rb
26
27
  - rails_reroute.gemspec
27
28
  homepage: http://github.com/NateBarnes/rails_reroute
@@ -33,17 +34,17 @@ require_paths:
33
34
  - lib
34
35
  required_ruby_version: !ruby/object:Gem::Requirement
35
36
  requirements:
36
- - - ">="
37
+ - - '>='
37
38
  - !ruby/object:Gem::Version
38
39
  version: '0'
39
40
  required_rubygems_version: !ruby/object:Gem::Requirement
40
41
  requirements:
41
- - - ">="
42
+ - - '>='
42
43
  - !ruby/object:Gem::Version
43
44
  version: '0'
44
45
  requirements: []
45
46
  rubyforge_project: rails_reroute
46
- rubygems_version: 2.2.2
47
+ rubygems_version: 2.4.5
47
48
  signing_key:
48
49
  specification_version: 4
49
50
  summary: Reroute rails requests fully