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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40d6031e236f4e0ecaad08587400227ecbc42f61eded9c4e446688ffb71e31a8
4
- data.tar.gz: 42910edc1ff8273520e7c09edfd9105d243bbfa5553fd63cdacafe219d6973aa
3
+ metadata.gz: 39a6633934992e197f4a6137b6baa5d99bf9b06d2e8e439b21c0114e30e67708
4
+ data.tar.gz: 2d2a8020e445f9c4e487c7b8fd36c799fe288254705c151ba5853d0a1cdd1de9
5
5
  SHA512:
6
- metadata.gz: 02b10db8fc9d4c64b38a388dd52d4639c3187dc344d62f666bca6697b4bc593d16e830fb1d01bdda33ba26868154191404e21a95d3491fc3f5383f2430230210
7
- data.tar.gz: 5eff94c8fc5571a4edc5743ac32173414a0b27a397c773b3170ad7c8bb5354599a890252b2c6d4e1c29cd77cfb7d0c17edaec6aeca77c5432ea35e74d0bd1c35
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
- session = Ritm::Session.new
18
+ _session = Ritm::Session.new
19
19
 
20
- port = @port
20
+ _port = @port
21
21
 
22
- session.configure do
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] = port
26
+ proxy[:bind_port] = _port
27
27
  end
28
28
 
29
- session.on_response do |_req, _resp|
29
+ _session.on_response do |_req, _resp|
30
30
 
31
31
  if api_list.include?(_req.path)
32
32
 
33
- _params = nil
34
- begin
35
- _params = JSON.parse(_req.body)
36
- rescue
37
- _params = _req.body
38
- end
33
+ puts "- - - > #{_req.path}"
39
34
 
40
- _result = JSON.parse(_resp.body)
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
- session.start
57
+ _session.start
63
58
 
64
59
  # trap 'INT' do
65
- # session.shutdown
60
+ # _session.shutdown
66
61
  # return
67
62
  # end
68
63
  # loop { gets }
@@ -1,3 +1,3 @@
1
1
  module Doraemon
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
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.1
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-05 00:00:00.000000000 Z
11
+ date: 2018-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler