c80_shared 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/c80_shared/middleware/images_proxy.rb +27 -24
- data/lib/c80_shared/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f140955495f30ac90304cbf160747257bf9022df1984217757bd5ecc777f246
|
4
|
+
data.tar.gz: b1384d344424ce86fdc1244c4026fe68facbad0d71b0ad08287144a3a36a4554
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fc249b394e59d22761e093edf9dbc323bf4d0c46fcf0e3bc879d9801048b12c1eda9e84508fa8a99554a96cc117897503bcddea9f2a08ebdb8edf1f1932d136
|
7
|
+
data.tar.gz: 79721b83844966f565d04b6e1a763211d47e3a7327a99a0de41d87d9335f2b7743087ca1f4ad3ebe5df13e0d17943efad62fb28fed64b8ef385f21ac48108572
|
data/.gitignore
CHANGED
@@ -13,34 +13,37 @@
|
|
13
13
|
# gem 'rack-proxy'
|
14
14
|
#
|
15
15
|
#
|
16
|
-
|
16
|
+
if defined?(Rack::Proxy)
|
17
|
+
class ImagesProxy < Rack::Proxy
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
NEED_FAKE = /(system|ckeditor)/i # в урле должно содержаться это, чтобы запрос ушёл на боевой
|
20
|
+
HOST = 'getboat.com:80'.freeze # боевой адрес + порт
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
def initialize(app)
|
23
|
+
@app = app
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
def call(env)
|
27
|
+
original_host = env['HTTP_HOST']
|
28
|
+
rewrite_env(env)
|
29
|
+
if env['HTTP_HOST'] != original_host
|
30
|
+
perform_request(env)
|
31
|
+
else
|
32
|
+
# just regular
|
33
|
+
@app.call(env)
|
34
|
+
end
|
33
35
|
end
|
34
|
-
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
def rewrite_env(env)
|
38
|
+
path = Rack::Request.new(env).path
|
39
|
+
if path =~ NEED_FAKE && !File.exists?(path)
|
40
|
+
env['HTTP_HOST'] = HOST
|
41
|
+
env['SERVER_PORT'] = 80
|
42
|
+
else
|
43
|
+
# do nothing
|
44
|
+
end
|
45
|
+
env
|
43
46
|
end
|
44
|
-
env
|
45
47
|
end
|
46
|
-
|
48
|
+
|
49
|
+
end
|
data/lib/c80_shared/version.rb
CHANGED