doraemon 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/doraemon/proxy_server.rb +10 -15
- data/lib/doraemon/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39a6633934992e197f4a6137b6baa5d99bf9b06d2e8e439b21c0114e30e67708
|
4
|
+
data.tar.gz: 2d2a8020e445f9c4e487c7b8fd36c799fe288254705c151ba5853d0a1cdd1de9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cc8090a09d2fb5d8962d24cdbf83a52cf84367dc01ba15afc7f101d684bf41d16a4ed557127f759075084375380e4ebd0617923dbcf301b5c795713382b3fa8
|
7
|
+
data.tar.gz: c9caeaf0074c6a85a5139fc4f844ae914912e5163916d971845850bf871a09b7cc8a7f1cad30237b98378e6f9d7430970c134d2bc1b35779dda598c02c718a88
|
@@ -15,29 +15,25 @@ module Doraemon
|
|
15
15
|
|
16
16
|
Cert.generate_cert
|
17
17
|
|
18
|
-
|
18
|
+
_session = Ritm::Session.new
|
19
19
|
|
20
|
-
|
20
|
+
_port = @port
|
21
21
|
|
22
|
-
|
22
|
+
_session.configure do
|
23
23
|
ssl_reverse_proxy.ca[:pem] = Cert.cert_path
|
24
24
|
ssl_reverse_proxy.ca[:key] = Cert.key_path
|
25
25
|
proxy[:bind_address] = '0.0.0.0'
|
26
|
-
proxy[:bind_port] =
|
26
|
+
proxy[:bind_port] = _port
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
_session.on_response do |_req, _resp|
|
30
30
|
|
31
31
|
if api_list.include?(_req.path)
|
32
32
|
|
33
|
-
|
34
|
-
begin
|
35
|
-
_params = JSON.parse(_req.body)
|
36
|
-
rescue
|
37
|
-
_params = _req.body
|
38
|
-
end
|
33
|
+
puts "- - - > #{_req.path}"
|
39
34
|
|
40
|
-
|
35
|
+
_params = begin JSON.parse(_req.body) rescue _req.body end
|
36
|
+
_result = begin JSON.parse(_resp.body) rescue {} end
|
41
37
|
|
42
38
|
begin
|
43
39
|
_result = eval(File.read(File.join(@root, api_list[_req.path])))
|
@@ -53,16 +49,15 @@ module Doraemon
|
|
53
49
|
_resp.header['content-length'] = _resp.body.bytesize
|
54
50
|
_resp.header['content-type'] = 'application/json;charset=UTF-8'
|
55
51
|
|
56
|
-
puts "- - - > #{_req.path}"
|
57
52
|
puts "#{JSON.pretty_generate(_result)}\n\n"
|
58
53
|
end
|
59
54
|
|
60
55
|
end
|
61
56
|
|
62
|
-
|
57
|
+
_session.start
|
63
58
|
|
64
59
|
# trap 'INT' do
|
65
|
-
#
|
60
|
+
# _session.shutdown
|
66
61
|
# return
|
67
62
|
# end
|
68
63
|
# loop { gets }
|
data/lib/doraemon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doraemon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zhuoyi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|