restpack-web 0.1.17 → 0.1.18
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/lib/restpack-web/app.rb +38 -12
- data/lib/restpack-web/version.rb +1 -1
- metadata +2 -2
data/lib/restpack-web/app.rb
CHANGED
@@ -2,11 +2,11 @@ require 'restpack-core-client'
|
|
2
2
|
|
3
3
|
module RestPack
|
4
4
|
module Web
|
5
|
-
class App
|
5
|
+
class App
|
6
6
|
def initialize(app, options = {})
|
7
7
|
p "RestPack::Web::App.initialize"
|
8
8
|
@app = app
|
9
|
-
|
9
|
+
|
10
10
|
options[:core_domain] ||= ENV['RESTPACK_CORE_SERVICE']
|
11
11
|
options[:access_key] ||= ENV['RESTPACK_ACCESS_KEY']
|
12
12
|
|
@@ -14,8 +14,9 @@ module RestPack
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def call(env)
|
17
|
+
env[:restpack] ||= {}
|
17
18
|
begin #TODO: GJ: cache should handle errors gracefully
|
18
|
-
|
19
|
+
|
19
20
|
|
20
21
|
host = env["SERVER_NAME"]
|
21
22
|
env[:restpack][:host] = host
|
@@ -27,17 +28,10 @@ module RestPack
|
|
27
28
|
env[:restpack][:application] = domain.application
|
28
29
|
env[:restpack][:domain] = domain
|
29
30
|
|
31
|
+
add_user env
|
30
32
|
|
31
|
-
|
32
|
-
if user_id
|
33
|
-
url = "http://:1234@localhost:1112/api/v1/users/#{user_id}.json"
|
34
|
-
p url
|
35
|
-
json = RestClient.get(url)
|
36
|
-
user = JSON.parse(json)['user']
|
37
|
-
env[:restpack][:user] = user
|
38
|
-
end
|
33
|
+
add_application_domains env
|
39
34
|
|
40
|
-
env[:restpack][:user_id] = user_id
|
41
35
|
rescue Exception => e
|
42
36
|
p "---"
|
43
37
|
p e.message
|
@@ -48,5 +42,37 @@ module RestPack
|
|
48
42
|
@app.call(env)
|
49
43
|
end
|
50
44
|
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def add_user(env)
|
49
|
+
user_id = env['rack.session'][:user_id]
|
50
|
+
if user_id
|
51
|
+
url = "http://:1234@localhost:1112/api/v1/users/#{user_id}.json" #TODO: GJ: build from config
|
52
|
+
p url
|
53
|
+
json = RestClient.get(url)
|
54
|
+
user = JSON.parse(json)['user']
|
55
|
+
env[:restpack][:user] = user
|
56
|
+
end
|
57
|
+
|
58
|
+
env[:restpack][:user_id] = user_id
|
59
|
+
end
|
60
|
+
|
61
|
+
def add_application_domains(env)
|
62
|
+
application = env[:restpack][:application]
|
63
|
+
|
64
|
+
domains = {}
|
65
|
+
|
66
|
+
configured_domains = application.get_configuration_by_key('domains')
|
67
|
+
|
68
|
+
if configured_domains
|
69
|
+
for key in configured_domains.value.keys
|
70
|
+
domains[key] = configured_domains.value[key]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
env[:restpack][:application_domains] = domains
|
75
|
+
end
|
76
|
+
|
51
77
|
end
|
52
78
|
end
|
data/lib/restpack-web/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restpack-web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.18
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack-auto-session-domain
|