emapic_consul 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/emapic_consul/api.rb +1 -1
- data/lib/emapic_consul/request.rb +26 -30
- data/lib/emapic_consul/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fac7c21d090de410148f5dbd32195b67bb901bd
|
4
|
+
data.tar.gz: 8ba6d152ba9f638f6de6f73522e757d146d1009c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57a45fe844ef517d8ea34977a796c04ac7bb527b94b8a5e1650d99d1b8244b01190bc5b20b2dd7ebc5eb51b9671e44c41712f1340be841b7355c62dd263ba5b5
|
7
|
+
data.tar.gz: d50f16080e8c19e04dfb682e5473a0cbec8045e1e181b2a7566d5773c1f524e548356ed902af8d33c28fb6e0f6d40ca738faa1d1939ae2f038adc07e50f9133a
|
data/lib/emapic_consul/api.rb
CHANGED
@@ -2,39 +2,35 @@ require 'net/http'
|
|
2
2
|
require 'openssl'
|
3
3
|
|
4
4
|
module EmapicConsul
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
@request.basic_auth(options[:api_key], options[:api_secret])
|
17
|
-
end
|
18
|
-
|
19
|
-
# usage:
|
20
|
-
# request.params = { id: 1, title: 'My title', geoloc: 'xyz' }
|
21
|
-
def params=(params)
|
22
|
-
@request.set_form_data(params)
|
23
|
-
end
|
24
|
-
|
25
|
-
def send
|
26
|
-
@http.request(@request)
|
27
|
-
end
|
5
|
+
class Request
|
6
|
+
def initialize(options = {})
|
7
|
+
uri = URI::HTTP.build(
|
8
|
+
host: options[:host],
|
9
|
+
path: options[:path],
|
10
|
+
port: options[:port]
|
11
|
+
)
|
12
|
+
@http = build_http_object(uri)
|
13
|
+
@request = Net::HTTP::Post.new(uri)
|
14
|
+
@request.basic_auth(options[:api_key], options[:api_secret])
|
15
|
+
end
|
28
16
|
|
29
|
-
|
17
|
+
# usage:
|
18
|
+
# request.params = { id: 1, title: 'My title', geoloc: 'xyz' }
|
19
|
+
def params=(params)
|
20
|
+
@request.set_form_data(params)
|
21
|
+
end
|
30
22
|
|
31
|
-
|
32
|
-
|
33
|
-
http.use_ssl = true
|
34
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
35
|
-
http
|
36
|
-
end
|
23
|
+
def send
|
24
|
+
@http.request(@request)
|
37
25
|
end
|
38
26
|
|
27
|
+
private
|
28
|
+
|
29
|
+
def self.build_http_object(uri)
|
30
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
31
|
+
http.use_ssl = true
|
32
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
33
|
+
http
|
34
|
+
end
|
39
35
|
end
|
40
36
|
end
|