dc_tunnel 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dc_tunnel.rb +15 -4
- 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: 2733e282c05ee8565fd8f3ecc16885d3eb3a305efbec81dc6ca0585722bd62d0
|
4
|
+
data.tar.gz: c371902ff187c786ce7dccf6ba203b4ec74ddab472abf7165289ca7dacfbcd9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef172b66de5888943da6ffc8e6de7f1f2b6203846d52b111272caeda8886c20901a9404953324530d3dfddd95966ed0bcec95420589c45c3c408d9976c1ab108
|
7
|
+
data.tar.gz: 045580fecf869c8e40fad102c7bea4981c9faa5923fce00498177cd71315b331cea5d702814106139a61371c940b6c6183ebedeb2265b0999201471a0f52717e
|
data/lib/dc_tunnel.rb
CHANGED
@@ -15,12 +15,22 @@ class DcTunnel
|
|
15
15
|
puts content
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
|
+
def error_handler(res)
|
20
|
+
integer_code = res.code.to_i
|
21
|
+
unless integer_code >=200 && integer_code < 400
|
22
|
+
render json: {
|
23
|
+
message: JSON.parse(res.body)['message']
|
24
|
+
}, :status => integer_code
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
19
28
|
def http_get(url)
|
20
|
-
self.logger '0.
|
29
|
+
self.logger '0.10'
|
21
30
|
self.logger "--- Tunnel : start get #{url} "
|
22
|
-
res = Net::HTTP.
|
23
|
-
|
31
|
+
res = Net::HTTP.get_response(URI(url))
|
32
|
+
self.error_handler res
|
33
|
+
res = JSON.parse(res.body)
|
24
34
|
self.logger "--- Tunnel : got parsed response #{res} "
|
25
35
|
res = res.symbolize_keys(true)
|
26
36
|
self.logger "--- Tunnel : got symbolize_keys! response #{res} "
|
@@ -30,6 +40,7 @@ class DcTunnel
|
|
30
40
|
def http_post(url, postdata={})
|
31
41
|
self.logger "--- Tunnel : start get #{url} "
|
32
42
|
res = Net::HTTP.post_form(URI(url), postdata).body
|
43
|
+
self.error_handler res
|
33
44
|
res = JSON.parse(res).symbolize_keys(true)
|
34
45
|
self.logger "--- Tunnel : got response #{res} "
|
35
46
|
res
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dc_tunnel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Qxchen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: advanced_hash_keys
|